0

I want to add a - dash after user has typed the first three numbers and then another dash after they typed another 4 numbers and append it back to the input text "#phone_number". Something like this, with maybe jquery preferably or javascript

<input type="text" name="phone_number" id="phone_number" value="" onkeyup="setnumberformatautomatically()" placeholder="Phone number here"> 

Lets Assume the USER typed 08012345678 it should turn to something like this 080-1234-5678 automatcially when the user is typing.

Then the JS

<script>
function setnumberformatautomatically(){
var phone_line = $("#phone_number").val(); 
//how do i go about this here please.
}
</scrript>
Shasha
  • 439
  • 8
  • 26
  • Does this answer your question? [How to change Phone number format in input as you type?](https://stackoverflow.com/questions/17980061/how-to-change-phone-number-format-in-input-as-you-type) – devlin carnate Jul 02 '20 at 15:16
  • @devlincarnate Thanks for your contribution, no its not. Will explain, the mask works perfectly for desktop, i used it before but when you come to mobile browsers, most browsers do not run it properly, the users text kind of get distorted with random numbers been added to it. – Shasha Jul 02 '20 at 15:22
  • There is more than one answer in that other question. And so, if none of those answers are working for you, then please update your question with the details explaining what you have tried, and how each attempt has failed. Otherwise, how are we to know how to answer your specific problem? – devlin carnate Jul 02 '20 at 15:46
  • @devlincarnate Okay will do that – Shasha Jul 02 '20 at 16:22

0 Answers0