您现在的位置是:首页 > 电脑技术查询 > web开发

验证只有字母的脚本或者正则,该怎么处理

编辑:chaxungu时间:2022-10-02 23:21:57分类:web开发

验证只有字母的脚本或者正则
文本框内只允许输入字母。
<INPUT NAME= "name " TYPE= "text " onChange()>
求function.....

------解决方案--------------------
<html>
<head>
<title> Javascript正则表达式 </title>
</head>
<body>
<script >
function regex()
{
var regex=/^[a-z]+$/i;
var str = document.form1.name1.value;
var result = regex.test(str);
alert(result);
}
</script>
<form name=form1>
<input type=text name=name1 >
<input type=button onClick= "regex() " value= "test ">
</form>
</body>
</html>

------解决方案--------------------
- -
貌似我少打个加号。嘿嘿。。
------解决方案--------------------
/^[A-Za-z]+$/

支持这个