Ralph
asked on
Simple Javascript problem
I'm NOT a javascripter; this should be easy -- but it aint working!
The alert shows the 4 digits I type.
The functions insists that phone_no is undefined.
What am I missing?
Thank you.
var wireless_no = $( "input[name=wireless_no]" ).val().trim() ;
alert(wireless_no) ;
wireless_no = wireless_no.strip_phone_format() ;
And my function:// *************************************************************************************************
String.prototype.strip_phone_format = function (phone_no)
{
var phone=phone_no.toString() ; // just in case. Chrome inspector says phone_no above is undefined.
var front=phone.replace("(","") ;
var middle=phone.replace(") ","") ;
var back=phone.replace("-","") ;
return front+middle+back ;
} ;
The alert shows the 4 digits I type.
The functions insists that phone_no is undefined.
What am I missing?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dumb mistake on my part. Thank you.
Also the code needed fixing, but that was easily done.
Also the code needed fixing, but that was easily done.
Open in new window
I would define the function simply as
Open in new window
and then use it like this:
Open in new window