javascript - How to change format of the phone number? -


at time, format next phone

123-123-1123 

i want have next form:

(123)456-7890 

how can change format whatever shape want?

<input class="" type="text" name="primary_phone" id="primary_phone" maxlength="10" placeholder="1234567890"> 
$("#primary_phone").blur(function() {     text = $(this).val().replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3");     $(this).val(text); }); 

http://jsfiddle.net/xxk3f/2864/

    var phone = "123-123-1123";      var newphone = "(" + phone.replace("-", ")");      alert(newphone);


Comments

  1. This page contains the necessary information about game. From here I am get some information.Have
    you played the famous akinator unblocked
    ? If not, you must play it today only as it is a quite amazing game which will give you some fun moments playing it in your busy day schedule

    ReplyDelete
  2. This page contains the necessary information The Samsung Galaxy M52 is going to be published very soon if you feel free you can visit my site Samsung M52 Release Date

    ReplyDelete

Post a Comment

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -