- <script language="javascript">
- <!--
- function isNumber(String)
- {
- var Letters = "1234567890-"; //可以自己增加可输入值
- var i;
- var c;
- if(String.charAt( 0 )=='-')
- return false;
- if( String.charAt( String.length - 1 ) == '-' )
- return false;
- for( i = 0; i < String.length; i ++ )
- {
- c = String.charAt( i );
- if (Letters.indexOf( c ) < 0)
- return false;
- }
- return true;
- }
- function CheckForm()
- {
- if(! isNumber(document.form.TEL.value)) {
- alert("您的电话号码不合法!");
- document.form.TEL.focus();
- return false;
- }
- return true;
- }
- -->
- </script>
- //该片段来自于http://www.codesnippet.cn/detail/140120131600.html
来源: http://www.codesnippet.cn/detail/140120131600.html