troubleshooting Question

Simple Javascript problem

Avatar of Ralph
RalphFlag for United States of America asked on
3 Comments1 Solution206 ViewsLast Modified:
I'm NOT a javascripter;  this should be easy -- but it aint working!

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.
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros