8 Replies Latest reply on Apr 25, 2007 8:04 AM by jdeline

    spaces in front of form entry values

    tapping Level 1
      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?
        • 1. Re: spaces in front of form entry values
          craigkaminsky Level 3
          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!
          • 2. Re: spaces in front of form entry values
            tapping Level 1
            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.
            • 3. Re: spaces in front of form entry values
              insuractive Level 3
              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?
              • 4. Re: spaces in front of form entry values
                tapping Level 1
                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>
                • 5. Re: spaces in front of form entry values
                  jdeline Level 1
                  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.
                  • 6. Re: spaces in front of form entry values
                    tapping Level 1
                    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>

                    • 7. Re: spaces in front of form entry values
                      insuractive Level 3
                      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.
                      • 8. spaces in front of form entry values
                        jdeline Level 1
                        > 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.