Try entering +447834756352 or 00447833464563 or 448337374657
It will take off the incorrect format and apply the correct format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<form name="dog"> <input type="text" name="phone" onchange="myphone()"> </form> <script> function myphone(){ var string = document.dog.phone.value; alert(string); string = string.replace(' ','');//no spaces string = string.replace('+',''); //no + sign document.write(string + " - START NUMBER<br>"); var howlong = string.length; if (howlong > 11) { // ***************************** if ((string[0] == 0)&&(string[1] == 0)&&(string[2] == 4)&&(string[3] == 4)) { alert("0044 found and trimmed"); string = string.substring(4); // string = string.setCharAt(1,'0'); string= "0"+string; } // ******************* if ((string[0] == 4)&&(string[1] == 4)) { alert("44 found and trimmed"); string = string.substring(2); string= "0"+string; } // ******************* alert(string); } } </script> |
or maybe try Trim-to-certain-length-get-specific-characters