<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://www.jb51.net/js\jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="https://www.jb51.net/js\MyValidate.js" type="text/javascript"></script>
<%--<script src="https://www.jb51.net/js\CheckPersonCardID.js" type="text/javascript"></script>--%>
</head>
<body>
<div>
<li>
<label for="email">
用户名:
</label>
<input type="text" maxlength="50" onblur="return ValidateHelper.validateStringValueIsEmpty($(this),'通过','不能为空');" /><em></em>
</li>
<li>
<label for="setPwd">
密码:
</label>
<input type="password" maxlength="16" onblur="return ValidateHelper.validateStringValueIsEmpty($(this),'通过','不能为空');" /><em></em>
</li>
<li>
<label for="setPwd">
身份证:
</label>
<input type="text" onblur="return ValidateHelper.validateStringValueForCardID($(this),'通过','身份证格式不正确');" /><em></em><%--IdCardValidate($(this),'身份证的格式不正确');--%>
</li>
<li>
<label for="setPwd">
Email:
</label>
<input type="text" onblur="return ValidateHelper.validateStringValueForEmail($(this),'通过','email格式不正确');" /><em></em>
</li>
<li><input type="button" /></li>
</div>
</body>
</html>
js:
复制代码 代码如下:
var Validation = {
textCount: function(field, counter, maxLimit) {
var message = $(field).val();
if ($(field).val().length > maxLimit)
$(field).val(message.substring(0, maxLimit))
//$(counter).text(maxLimit-field.value.length);
},
refreshValidator: function(img, input) {
$(img).attr('src', $(img).attr('src') + "&r=" + Math.random());
$(input).focus();
},
isUrl: function(s) {
var strRegex =
/^((http(s)?|ftp|telnet|news|rtsp|mms):\/\/)?(((\w(\-*\w)*\.)+[a-zA-Z]{2,4})|(((1\d\d|2([0-4]\d|5[0-5])|[1-9]\d|\d).){3}(1\d\d|2([0-4]\d|5[0-5])|[1-9]\d|\d).?))(:\d{0,5})?(\/+.*)*$/;
return strRegex.test(s);
},
isDecimal: function(d) { var pattern = /^(([1-9]\d{0,12})|0)(\.\d{1,2})?$/; return pattern.test(d); },
isEmail: function(s) {
var pattern = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
return pattern.test(s);
},
isLowEmail: function(s) {
var b, e;
b = s.indexOf("@");
e = s.indexOf(".");
if (b <= 0) return false;
if (e < 0 || e == (s.length - 1)) { return false; }
return true;
},
clearNoNum: function(event, obj) {
event = window.event || event;
if (event.keyCode == 37 | event.keyCode == 39) {
return;
}
obj.value = obj.value.replace(/[^\d.]/g, "");
obj.value = obj.value.replace(/^\./g, "");
obj.value = obj.value.replace(/\.{2,}/g, ".");
obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
},
checkNum: function(obj) {
obj.value = obj.value.replace(/\.$/g, "");
},
isInteger: function(value) {
var integerReg = new RegExp(/^\d+$/);
return integerReg.test(value);
},
isValidateReg: function(value) {
var validateReg = /^([A-Za-z0-9\s\-\_\~\!\@\#\$\%\^\&\*\(\)\|\<\>\?\:\;\"\'\.\[\]\{\}\,\+\`\/\\\=]){6,16}$/;
if (validateReg.test(value)) {
return true;
}
return false;
},
isDate: function(strValue) {
var objRegExp = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/