Use JS to verify the input is a mobile phone number or phone number, here is a good example, interested friends can refer to the following
Code as follows: code as follows: <script type= "Text/javascript" > String.prototype.Trim = function () { var m = This.mat CH (/^s* s+ (s+s+) *) s*$/); return (M = = null)? ' ': m[1]; } String.prototype.isMobile = function () { return (/^ (?: 13d|15[89))-?d{5} (D{3}|*{3}). Test (this. Trim ()); } String.prototype.isTel = function () { //"compatible Format: Country code (2 to 3 bits)-Zip code (2 to 3 digits)-Phone number (7 to 8 digits)-Extension number (3-bit) " //return (/^) ([0+]d{2,3}-)? ( 0d{2,3})? (d{7,8}) (-(D{3,}))? $/.test (this. Trim ())); return (/^ ([0+]d{2,3}-)? 0d{2,3})-(d{7,8}) (-(D{3,})? $/.test (this. Trim ()); } function Chkform () { with (Document.form1) { if (tel.value.isMobile () | | Tel.value.isTel ()) { Tel.value = Tel.value.Trim (); alert ("Your phone/mobile number is:" + tel.value); return true; } Else { alert ("Please enter the correct cell phone number or phone number nn for example: 13916752109 or 0712-3614072"); Tel.focus (); return false; } } } </script> <form name= "Form1"Method= "POST" action= "" > <input type= "Text" name= "tel" value= "13916752109" size= ""/> <input Type= "button" value= "Test" onclick= "return Chkform ()"/> </form>