验证输入是否数字
function isNumeric(obj)
{
if((parseInt(obj.value))!=obj.value)
{
return false;
}
return true;
}
感觉还是用javascript好
function isNumeric(obj)
{
if((parseInt(obj.value))!=obj.value)
{
return false;
}
return true;
}
感觉还是用javascript好
String.prototype.is_InSign = function() {
return (this.replace(/[^\x00-\xff]|[a-z0-9]/ig,"").length > 0);
}
s = "不能输入任何符号abcd12-345";
if(s.is_InSign)
alert("有符号");
</script>
alert("有非法字符");
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script>
String.prototype.is_InSign = function() {
return (this.replace(/[^\x00-\xff]|[a-z0-9]/ig,"").length > 0);
}
document.form1.Name= "不能输入任何符号abcd12-345";
if(document.form1.Name.is_InSign)
alert("有非法字符");
</script>
</head>
<body>
<FORM name=form1 action="" method=post>
<input type="text" name="Name">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
还是不行.
这些代码我看不懂.我应该看些什么书啊?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script>
String.prototype.is_InSign = function() {
return (this.replace(/[^\x00-\xff]|[a-z0-9]/ig,"").length > 0);
}function mysubmit(form) {
if(form.Name.value.is_InSign()) {
alert("有非法字符");
return false;
}
}
</script>
</head>
<body>
<FORM name=form1 action="" method=postt onSubmit="return mysubmit(this)">
<input type="text" name="Name">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
只能输入英文和数字<input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeydown="if(event.keyCode==13)event.keyCode=9"> <br>