How to remove blank spaces (in addition to hyphens) in SSN

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 5141 Views - Last Post: 04 August 2010 - 12:53 PM Rate Topic: -----

#1 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 09:59 AM

A while ago, I got help with removing the hyphen (-) in Social Security Numbers in the input textbox. It worked (Thx again). Now I need to remove any blank spaces in the SSN. I tried the ISO 8859-1 Entity Number ' ' but it didn't work; I kept getting an 'Invalid CFML construct' error message. Then I tried the ASCII character '32' but it prompted an error message that I had written for another instance on the form page. Now the codes for removing the hyphens stop working. This happened after I added some validation on the form page:

Here is the added validation on the form page:
<input type="hidden" name="form.OldSSN_cfinteger" value="SSN field must contain numbers only>
...
<input type="hidden" name="form.NewSSN_cfinteger" value="SSN field must contain numbers only>



Here is the existing Replace() code on the action page:
<cfset form.OldSSN = Replace(form.OldSSN, "-", chr(0), "ALL")>
<cfset form.NewSSN = Replace(form.NewSSN, "-", chr(0), "ALL")>



And the new Replace() code added after the above:
<cfset form.OldSSN = Replace(form.OldSSN, chr(32), chr(0), "ALL")>
<cfset form.NewSSN = Replace(form.NewSSN, chr(32), chr(0), "ALL")>




Thanks again.

Is This A Good Question/Topic? 0
  • +

Replies To: How to remove blank spaces (in addition to hyphens) in SSN

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 10:23 AM

<cfset form.OldSSN = Replace(form.OldSSN, " ", "", "ALL")>
<cfset form.NewSSN = Replace(form.NewSSN, " ", "", "ALL")>


Was This Post Helpful? 0
  • +
  • -

#3 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 10:32 AM

On of the best ways that I have found to do SSNs is to actually use three text fields. Limit all through (on the client side) to be numeric. The first also needs to be limited to 3 characters, the second to 2 characters, and the third to 4 characters. Also make them auto jump to the next text field.
Was This Post Helpful? 0
  • +
  • -

#4 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 10:45 AM

View PostCraig328, on 03 August 2010 - 09:23 AM, said:

<cfset form.OldSSN = Replace(form.OldSSN, " ", "", "ALL")>
<cfset form.NewSSN = Replace(form.NewSSN, " ", "", "ALL")>



Hi Craig328,

I tried your code
<cfset form.OldSSN = Replace(form.OldSSN, " ", "", "ALL")>  
<cfset form.NewSSN = Replace(form.NewSSN, " ", "", "ALL")> 


but it did not work.

View Postxheartonfire43x, on 03 August 2010 - 09:32 AM, said:

On of the best ways that I have found to do SSNs is to actually use three text fields. Limit all through (on the client side) to be numeric. The first also needs to be limited to 3 characters, the second to 2 characters, and the third to 4 characters. Also make them auto jump to the next text field.


Hi xheartonfire43x,

How do I do it?
Was This Post Helpful? 0
  • +
  • -

#5 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 10:48 AM

Didn't work? Really?

Tell you what, try this and tell us what you get for output:

<cfoutput>form.OldSSN: [#form.OldSSN#]<br>form.NewSSN: [#form.NewSSN#]<p></p></cfoutput>
<cfset form.OldSSN2 = ReplaceNoCase(form.OldSSN, " ", "", "ALL")> 
<cfset form.NewSSN2 = ReplaceNoCase(form.NewSSN, " ", "", "ALL")>
<cfoutput>form.OldSSN2: [#form.OldSSN2#]<br>form.NewSSN2: [#form.NewSSN2#]</cfoutput>



It's just spaces, right? Should cull them right out...but let's see the results of those outputs and we'll figure out what's going wrong.
Was This Post Helpful? 0
  • +
  • -

#6 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 11:28 AM

I tried your code and it kept prompting for the following error message that I had written on the form page for in case the current (old) SSN does not exist, although it DOES exist:

<cfelseif IsDefined("url.success") AND #url.success# EQ "NO">  
  <div style="color:red"><strong>
    The Current SSN you entered does NOT exist.<br>
  </div>



And the code (on the action page) that prompts the message is:
<cfelseif #form.Submit# EQ "Change SSN" AND qryOldSSN.recordcount EQ 0>
  <cflocation url="dsp_SSN_modify.cfm?success=NO"  addtoken="No"> 


Was This Post Helpful? 0
  • +
  • -

#7 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 12:16 PM

Okay. Let's start over. On your action page (the page you're submitting the SSN field to) put this at the top of the page and post back here with what it shows.

<cfdump var="#form#"><cfabort>



That's going to dump all the incoming form elements to the screen and then promptly stop processing. Paste the output here and from there we can tell you how to format your SSN numbers.
Was This Post Helpful? 0
  • +
  • -

#8 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 12:49 PM

Here is the result:

struct
FIELDNAMES FORM.OLDSSN,FORM.NEWSSN,FORM.STRAUDITACTION,SUBMIT
FORM.NEWSSN 111 11 1112
FORM.OLDSSN 111111111
FORM.STRAUDITACTION [empty string]
SUBMIT Change SSN
Was This Post Helpful? 0
  • +
  • -

#9 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 12:56 PM

View Postcamcode, on 03 August 2010 - 11:49 AM, said:

Here is the result:

struct
FIELDNAMES FORM.OLDSSN,FORM.NEWSSN,FORM.STRAUDITACTION,SUBMIT
FORM.NEWSSN 111 11 1112
FORM.OLDSSN 111111111
FORM.STRAUDITACTION [empty string]
SUBMIT Change SSN


Okay. You have the form.newssn variable as showing as '111 11 1112'. To get that to show without spaces and the like (and you can do this for oldssn as well) try this:

<cfset form.newssn = ReplaceNoCase(Trim(form.newssn)," ","","ALL")>
<cfdump var="#form#">
<cfabort>


Run that and see what you get.

This post has been edited by Craig328: 03 August 2010 - 12:56 PM

Was This Post Helpful? 0
  • +
  • -

#10 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 03 August 2010 - 01:28 PM

This time I got:

struct
FIELDNAMES FORM.OLDSSN,FORM.NEWSSN,FORM.STRAUDITACTION,SUBMIT
FORM.NEWSSN 111 11 1112
FORM.OLDSSN 111 11 1111
FORM.STRAUDITACTION [empty string]
NEWSSN 111111112
OLDSSN 111111111
SUBMIT Change SSN
Was This Post Helpful? 0
  • +
  • -

#11 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 04 August 2010 - 06:13 AM

Isn't that what you wanted though? The spaces and hyphens removed?
Was This Post Helpful? 0
  • +
  • -

#12 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 04 August 2010 - 10:17 AM

View PostCraig328, on 04 August 2010 - 05:13 AM, said:

Isn't that what you wanted though? The spaces and hyphens removed?


Hi Craig328,

It finally worked this morning. It did not work yesterday even though after I restarted the application; I don't know why. But it's working now. Thank you so much for all your help and patience.

This is a great site.
Was This Post Helpful? 0
  • +
  • -

#13 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 04 August 2010 - 11:09 AM

No problem. Glad you got it handled.

As an aside, it could have been your browser settings (particularly IE) that caused you a problem. Under Internet Options/Browsing history/Settings you'll see a setting entitled "Check for newer versions of stored pages". IE's default is "automatically". Change that to "Everytime I visit the webpage". Sometimes what IE does is it caches the page that comes up per URL.

So, for instance, if you had a URL like "http://www.somesite.com/home.cfm" and that home page has code that presents dynamic (changing) data as output...IE might cache the page the first time you go to it and then present the cached version to you instead of actually calling the page again. Used to be a much bigger problem back in the day but it still rears its head from time to time.
Was This Post Helpful? 0
  • +
  • -

#14 camcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-June 10

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 04 August 2010 - 11:26 AM

View PostCraig328, on 04 August 2010 - 05:13 AM, said:

Isn't that what you wanted though? The spaces and hyphens removed?


View PostCraig328, on 04 August 2010 - 05:13 AM, said:

Isn't that what you wanted though? The spaces and hyphens removed?


I used to think that the TRIM() function only removes the first and last characters of the string. I didn't know that it can also remove characters in between.
Was This Post Helpful? 0
  • +
  • -

#15 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1943
  • View blog
  • Posts: 3,481
  • Joined: 13-January 08

Re: How to remove blank spaces (in addition to hyphens) in SSN

Posted 04 August 2010 - 11:28 AM

View Postcamcode, on 04 August 2010 - 10:26 AM, said:

I used to think that the TRIM() function only removes the first and last characters of the string. I didn't know that it can also remove characters in between.


It doesn't. It just removes leading and trailing spaces and control characters from a string. The function the removes them from inside the string is the ReplaceNoCase() function.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2