function check()
{
var bb = document.getElementById("txt_id").value;//txt_id为文本框的ID
alert(ismobile(bb));//ismobile 代表以下任何一个函数名称 }
<input type="text" name="textfield" id="txt_id" /> <input type="submit" name="Submit" value="提交" onclick="check()" />
function isalphanumber(str){
var result=str.match(/^[a-zA-Z0-9]+$/);
if(result==null) return false;
return true;
}
function isnumber(str)
{
return !isNaN(str);
}
function isint(str)
{
var result=str.match(/^(-|\+)?\d+$/);
if(result==null) return false;
return true;
}
"YYYY-MM-DD HH:MM:SS" || "YYYY/MM/DD HH:MM:SS"
function isdatetime(str)
{
var result=str.match(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
if(result==null) return false;
var d= new Date(result[1], result[3]-1, result[4], result[5], result[6], result[7]);
return (d.getFullYear()==result[1]&&(d.getMonth()+1)==result[3]&&d.getDate()==result[4]&&d.getHours()==result[5]&&d.getMinutes()==result[6]&&d.getSeconds()==result[7]);
}
function isdate(str){
var result=str.match(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(result==null) return false;
var d=new Date(result[1], result[3]-1, result[4]);
return (d.getFullYear()==result[1] && d.getMonth()+1==result[3] && d.getDate()==result[4]);
}
function isemail(str)
{
var result=str.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/);
if(result==null) return false;
return true;
}
function trim(str){
return str.replace(/(^\s*)|(\s*$)/g, "");
}
function strlen(str){
return str.replace(/[^\x00-\xff]/g, "**").length;
}
function ispostcode(str)
{
var result=str.match(/[1-9]\d{5}(?!\d)/);
if(result==null) return false;
return true;
}
function istell(str)
{
var result=str.match(/\d{3}-\d{8}|\d{4}-\d{7}/);
if(result==null) return false;
return true;
}
function isint1(str)
{
var result=str.match(/^[0-9]$|^([1-9])([0-9]){0,3}$|^10000$/);
if(result==null) return false;
return true;
}
function isqq(str)
{
var result=str.match(/[1-9][0-9]{4,}/);
if(result==null) return false;
return true;
}
function isidcard(str)
{
var result=str.match(/\d{15}|\d{18}/);
if(result==null) return false;
return true;
}
function checknull(field,sval)
{
if (field.value =="")
{
alert("请填写" + sval + "!");
field.focus();
return false;
}
return true;
}
function checkChar()
{
var keycode = event.keyCode;
if(!(keycode>=48&&keycode<=57))
{
return false;
}
}
function NotNull (str) { return (str!=""); }
function checkEmail (str) {
isEmail1=/^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
isEmail2=/^.*@[^_]*$/;
return (isEmail1.test(str)&&isEmail2.test(str)); }
function checkIDCard (str) {
isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;
return (isIDCard1.test(str)||isIDCard2.test(str)); }
function checkIP (str) {
IP='(25[0-5]|2[0-4]\\d|1\\d\\d|\\d\\d|\\d)';
IPdot=IP+'\\.'; isIPaddress=new RegExp('^'+IPdot+IPdot+IPdot+IP+'$');
return (isIPaddress.test(str)); }
function checkHomepage (str) {
//isHomepage=/^\w+([\.\-]\w)*$/; isHomepage=/^\w+(\.\w+)+\.\w+$/;
return (isHomepage.test(str)); }
function isNum (str) { //isNumber=/^([1-9]\d*(\.\d+)?)|(\d+(\.\d+))$/; isNumber=/^\d+(\.\d+)?$/;
return (isNumber.test(str)); }
function isInt (str) { isInteger=/^\d+$/;
return (isInteger.test(str)); }
function isChar (str) { isCharacter=/^[A-Za-z]+$/;
return (isCharacter.test(str)); }
function checkElement_selected(item,alert_str) {
if(item.type=="select-one")return checkElement_NotNull(item,alert_str);
if(alert_str.length==0)alert_str=item.title+"为必选项!";
rt=false; if(item.length>0) { for(i=0;i<item.length;i++)
{
rt=rt||item[i].checked;
} }
else
{
rt=item.checked } return checkBoolean(rt,item[0],alert_str); return true;
}
function checkElement_NotNull(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_NotNull(v,a,w,g)); } function checkValue_NotNull(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=NotNull(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsEmail(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsEmail(v,a,w,g)); }
function checkValue_IsEmail(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=checkEmail(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsIDCard(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsIDCard(v,a,w,g)); }
function checkValue_IsIDCard(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=checkIDCard(v);
return(checkBoolean(bv,i,w)); }
IP function checkElement_IsIP(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsIP(v,a,w,g)); } function checkValue_IsIP(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=checkIP(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsNum(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsNum(v,a,w,g)); } function checkValue_IsNum(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=isNum(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsInt(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsInt(v,a,w,g)); } function checkValue_IsInt(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, "");
bv=isInt(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsChar(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsChar(v,a,w,g)); } function checkValue_IsChar(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=isChar(v); return(checkBoolean(bv,i,w)); }
function checkElement_IsHomepage(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!";
return(checkValue_IsHomepage(v,a,w,g)); } function checkValue_IsHomepage(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^\s*)|(\s*$)/g, ""); bv=checkHomepage(v); return(checkBoolean(bv,i,w)); }
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有