function ComMethod()
{
var PARAMETERSPOSTCODE = /^[1-9]{1}[0-9]{5}$/; //邮编
}ComMethod.prototype.CheckPostCode = function (str) {
with (this) {
if (PARAMETERSPOSTCODE.test(str))
return true;
return false;
}
}
这样写不行啊
<body>
<input type="text" id="mail"/>
<input type="button" value="验证" onclick="ComMethod.prototype.CheckPhoneNumber(mail.value)" />
</body>
{
var PARAMETERSPOSTCODE = /^[1-9]{1}[0-9]{5}$/; //邮编
}ComMethod.prototype.CheckPostCode = function (str) {
with (this) {
if (PARAMETERSPOSTCODE.test(str))
return true;
return false;
}
}
这样写不行啊
<body>
<input type="text" id="mail"/>
<input type="button" value="验证" onclick="ComMethod.prototype.CheckPhoneNumber(mail.value)" />
</body>
if (!PARAMETERSPOSTCODE.test(str))
return true;
return false;
评注:中国邮政编码为6位数字function checkNum(obj)
{
var re = [1-9]\d{5}(?!\d);
if (!re.test(obj.value))
{
alert("邮编不对!");
obj.value="";
obj.focus();
return false;
}
return true;
}
ComMethod.prototype.CheckPhoneNumber
ComMethod.prototype.CheckPostCode//要调用到这个方法吧
ComMethod.prototype.CheckPostCode = function (str) {
alert("我被触法了");