I have for example: (111) 222-3333 – Verizon … I want to when I select this fill in two text box. The first textbox having (111) 222-333 and in the second textbox with Verizon. Is this possbile with jquery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sounds like the job for a regular expression:
A bit of searching should turn up a more robust regular expressions to match phone numbers.
Also – you can use jQuery to help you move the result values around, i.e.,
$('#number_text_box').text(result[1]);, but the regular expression is a javascript thing, it doesn’t depend on jQuery.Update: this expression adds capturing groups,
( )around each individual part of the number.You can then glue the numbers together:
A good place to experiment is in the browser itself – in Firebug or Webkit’s console, you can run javascript like this directly to test it out.