<script>
function check(obj){
if (obj.value.match(/^[a-zA-Z][\d\w\s]*/)) { //注意:[\d\w\s]可以根据你的需要具体的制定允许的字符
alert(obj.value+" is well formed!");
}
else {
alert(obj.value+" is not well formed!");
obj.value = "";
}
}
</script>
<html>
<input type="text" onblur="check(this)"></input>
</html>
<script>
function check(obj){
if (obj.value.match(/^[a-zA-Z][\d\sa-zA-Z]*$/)) {
alert(obj.value+" is well formed!");
}
else {
alert(obj.value+" is not well formed!");
obj.value = "";
}
}
</script>
<html>
<input type="text" onblur="check(this)"></input>
</html>
function check(obj){
if (obj.value.match(/^[a-zA-Z]{1}[.+]*/)) {
alert(obj.value+" is well formed!");
}
else {
alert(obj.value+" is not well formed!");
obj.value = "";
}
}
</script>
<input type="text" onblur="check(this)"></input>
function check(obj){
if (obj.value.match(/^[a-zA-Z]{1}[^\u4E00-\u9FA5]+$/)) {
alert(obj.value+" is well formed!");
}
else {
alert(obj.value+" is not well formed!");
obj.value = "";
}
}
</script>
<input type="text" onblur="check(this)"></input>
改成
if (obj.value.match(/^[a-zA-Z][^\u3400-\u9FFF]*$/)) {