Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing format using javascript

<input name="textfield" type="text" id="textfield" value="6267973685" /> Enter number like this and in next field it will display like this
<input name="textfield2" type="text" id="textfield2" value="(626) 797-3685" />

I want this to be done using JavaScript i had tried this a lot but not find any success please help me in it.

like image 347
Harsimran singh Avatar asked Nov 20 '25 00:11

Harsimran singh


1 Answers

You can use this nice light weight plugin Masked input plugin for the jQuery

$("#textfield").mask("(999) 999-9999");
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//digitalbush.com/wp-content/uploads/2014/10/jquery.maskedinput.js"></script>


<input name="textfield" type="text" id="textfield" value="6267973685" />
<br/>
Enter number like this and in next field it will display like this
<br/>
<input name="textfield2" type="text" id="textfield2" value="(626) 797-3685" />
like image 105
Kishore Sahasranaman Avatar answered Nov 21 '25 13:11

Kishore Sahasranaman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!