INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Format SSN Input Box

Format SSN Input Box

(OP)
I have an input box I would like to format. If the user enters as all numbers it shoud format as xxx-xx-xxxx. If a user enters as xxx-xx-xxxx then the formating should remain. I have the following code:

Code for the input box:

CODE --> javascript

+ '<td class="plaintablecell" nowrap><span id="ficaspan"><input class="inputbox" type="text" name="ficanbr" size="11" maxlength="11" onChange="javascript:this.value=parent.fixSSN(this.value)" onfocus="this.select()"' 

Code for the fixSSN function:

CODE --> javascript

function fixSSN(str)
{
	var str = new String(str); 
	str = str.replace(/[A-Za-z$-()\.]/g, '');
	str = str.replace(/[^0-9]/g, ''); 	
	str = str.replace( /[^\d]/g, '' );
	str = str.replace(/(\d{3})(\d{2})(\d{4})/, '$1-$2-$3');
	//alert(str);
	return str;
} 

This used to work but now returns, "Error: Object doesn't support property or method 'fixSSN'"

Any help would be greatly appreciated! Thanks!

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)

RE: Format SSN Input Box

Has the fixSSN function been attached to the parent element as a method of the object?

Prototype

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Format SSN Input Box

(OP)
Chris,

The first line of code I posted has this: onChange="javascript:this.value=parent.fixSSN(this.value)"

Is this what you are referring to? Like I said, this used to work but now it doesn't. We did go through an upgrade of the application this fixSSN function was placed into. Not sure if the javascript needs tweaking or if it is something else.

Thanks!

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)

RE: Format SSN Input Box

delete the 'parent.'

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close