<html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="http://cloud.github.com/downloads/digitalBush/jquery.maskedinput/jquery.maskedinput-1.3.min.js"></script> <script type="text/javascript">//<![CDATA[ $(window).load(function(){ $("#phone").mask("+?99 (999)-999-99-99"); $("#phone").on("blur", function() { var last = $(this).val().substr( $(this).val().indexOf("-") + 1 ); if( last.length == 3 ) { var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 ); var lastfour = move + last; var first = $(this).val().substr( 0, 9 ); $(this).val( first + '-' + lastfour ); } }); });//]]> </script> </head> <body> <form action="" method="get"> <input type="text" name="tel" id="phone" value="90"> </form> </body></html> <?php function tel($num) { $nums=str_replace(array("+"," ","(",")","-"),array("00","","","",""),$num); if(is_numeric($nums) AND strlen($nums) == 14){ return $num; }else{ return false; } } function num($num) { $num=str_replace(array("+"," ","(",")","-"),array("00","","","",""),$num); if(is_numeric($num) AND strlen($num) == 14){ $num = preg_replace('/[^0-9]/', '', $num); return $num; }else{ return false; } } echo tel($_GET["tel"]); echo "<br>"; echo num($_GET["tel"]); ?>