Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2003, 06:17 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default WhiteSpace problem

Hi All,

When loading a form, some of my field are pre-populated from the querystring. Where these values may have spaces, on the querystring they appear as %20 and so as a result, I would only get the field's being half populated (e.g. if a Postcode of CM6 1WP was entered the querystring would be CM6%201WP. The forms textbox would only show CM6.

To aleviate this problem, I introduced:
<input maxlength=12 size=8 name=""Postcode"" value=" & replace(strPostcode," ","&nbsp;") & ">

which on an initial load of the form works.

However, the user then goes through the remainder of the form entering details. Then the user presses the save button. At this point some basic validation in the head section is performed such as formating etc. As part of this the postcode is checked for correct format. First time through it's all ok. The form then post's to itself and some serverside checking is done. If servere side checking fails, then the textboxes are re-populated using request.form method to allow the user to change the offending data. The user then presses the save button again and again the postcode is checked from the head section. But this time fails format validation even though the postcode hasn't been touched by the user. If the postcode had been overtyped with the same value, then it would have passed. I cannot figure out why it fails on a re-post of the page. I have tried hardcoding the value so that it's not taken from the form object, but it makes no difference.

Help please :(

 
Old December 3rd, 2003, 09:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hmmm, did you try to enclose the value attribute it quotes?

<input maxlength="12" size="8" name="Postcode" value="Your Value">

If you need to write them out using ASP, use double quotes:

Response.Write("<input maxlength=""12"" size=""8"" name=""Postcode"" value=""Your Value"">")

If you don't use quotes for the attribute value, the browser will consider the first space as the end of the attribute value.

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 4th, 2003, 05:11 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

placing a response.write(request.form) revealed that an unprintable + was replacing the whitespace. Moving my <HTML> tag above my script resolved the issue






Similar Threads
Thread Thread Starter Forum Replies Last Post
separate a string with whitespace petergoodman XSLT 8 July 8th, 2008 01:56 AM
In IE6 How do you get Whitespace??? David P. Manning CSS Cascading Style Sheets 0 April 24th, 2007 08:01 AM
databinding to a textbox, whitespace problem bazookajoe76 C# 5 January 19th, 2005 02:39 PM
whitespace in label Twinklestar ASP.NET 1.0 and 1.1 Basics 4 July 28th, 2004 07:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.