整數5位或小數3位 /^[0-9]{1,5}(\.[0-9]{1,3})?$/
整數 /^[0-9]/
<input type="text" name="name1" value ="123" onblur="checkInput(this,this.value)"></input> <script language="javascript" type="text/javascript">//Added by Sting -- 2011/10/03 function checkInput(obj,v){ v = v.replace(/\,/g, ""); if(v != "") { var pattern = new RegExp(/^[0-9]+(\.[0-9]+)?$/); if(!pattern.test(v)){ alert("Please enter the number!"); obj.select(); return false; }}} </script>
沒有留言:
張貼留言