• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

spaces in front of form entry values

New Here ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

I have a form that submits to itself. After submiting the form, and if there is a user error, the form entry values are brought back with a space in front of the value. For example the first three digits of a ssn number bring back a space + 428.

Is there a way to keep the values from coming back with a space in front?
TOPICS
Advanced techniques

Views

708

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

Use the Trim function, which trims white space.

In a form field, it might look something like this:
<cfoutput>
<input type="text" name="myField" value='#Trim(myValue)#"/>
</cfoutput>

HTH!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

I am already using the trim function. There is still a space in front of the entries after the page reloads. It may have something to do with browsers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

Have you tested with IE and Firefox? If it happens with both browsers, that it probably is not a browser issue.

I've noticed CF places spaces sometimes when I'm calling user defined functions (UDF) and outputing the results to the screen instead of saving the value to a variable. Do you do any UDF processing of your form data?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

I am not using many udf. Sample of form entry code below:

<input name="ssn1" type="text" id="ssn1" <cfif isdefined("form.ssn1")> value = "<cfoutput> #form.ssn1#</cfoutput>" <cfelse> value = "<cfoutput>***</cfoutput>"</cfif> onKeyUp ="validotherssn(this);" size="3" maxlength="3" align="left" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" >
<input name="ssn2" type="text" id="ssn2" <cfif isdefined("form.ssn2")>value = "<cfoutput> #form.ssn2#</cfoutput>"<cfelse> value = "<cfoutput>**</cfoutput>" </cfif>
size="2" maxlength="2" onkeyup="validotherssn(this);" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" >
<input name="ssn3" type="text" id="ssn3" <cfif isdefined("form.ssn3")>value = "<cfoutput> #form.ssn3#</cfoutput>" <cfelse> value = "<cfoutput>****</cfoutput>"</cfif> onKeyUp="validotherssn(this);" size="4" maxlength="4" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" > </td>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

If you are already doing a Trim( ), perhaps the "space" is some other non-printing character - a tab, cr, lf, etc. Do an Asc(Left(form.ssn1)) and see what the ASCII character is.

And you don't need all those <CFOUTPUT></CFOUTPUT> in your code. It clutters up the landscape and makes it difficult to read. <CFOUTPUT> at the beginning and </CFOUTPUT> at the end will do the job just fine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2007 Apr 24, 2007

Copy link to clipboard

Copied

I wrote the following code in the form. Return value was 52. I entered 425 as the value of ssn1.

<cfif isdefined("form.ssn1")><CFOUTPUT>#Asc(Left(form.ssn1,1))#</CFOUTPUT> </cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 25, 2007 Apr 25, 2007

Copy link to clipboard

Copied

I think your problem is the space between <cfoutput> and your actual SSN

Try this:

"<cfoutput>#myVar#</cfoutput>"

instead of "<cfoutput> #myVar# </cfoutput>

Or better yet, surround the whole <td> with <cfoutput> so you don't have to keep reusing cfoutput blocks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 25, 2007 Apr 25, 2007

Copy link to clipboard

Copied

LATEST
> I wrote the following code in the form. Return value was 52. I entered 425 as
> the value of ssn1.

> <cfif isdefined("form.ssn1")><CFOUTPUT>#Asc(Left(form.ssn1,1))#</CFOUTPUT>
> </cfif>

Then the first character of form.ssn1 is a 4, not a space or other non-printable character. And I agree with insuractive, the space after <CFOUTPUT> is probably giving you problems.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation