Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format SSN Input Box

Status
Not open for further replies.

FireGeek21

Technical User
Dec 12, 2007
218
US
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:
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:

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)
 
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
 
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top