87,997
社区成员




<script type="text/javascript">
function CheckForm(oForm)
{
//取得表单的值,用通用取值函数
var patt = document.getElementById("che").getAttribute("check");
var sVal = document.form1.che.value;
// patt = "^\\S+$";
var reg = new RegExp(patt);
if (!reg.test(sVal))
{
//验证不通过,弹出提示warning
alert(document.getElementById("che").getAttribute("warning"));
return false;
}
return true;
}
</script>
<form onsubmit="return CheckForm(this)" name="form1">
<input type="text" id="che" name="che" check="^\\S+$" warning="id不能为空,且不能含有空格">
<input type="submit" />
</form>