这个文件是在项目过程中慢慢积累的,功能不是很多,但是完全满足了现在的项目需求,以后还会慢慢加全,希望大家支持。
/*
AspirinCheck v1.0
code by aspirin
thinking814@hotmail.com
*/
function AspirinCheck(){
var i =1;
var ipCk = ipCk=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}$)/g;
var numberCk=/^\d+$/g;
//Email:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$ //例子<input name="Email" dataType="Email" msg="信箱格式不正确">
/*参考的ip控件
<span class="ipInput" id="bip">
<input
name="broadCastIpOne" MAXLENGTH=3 onkeydown="nextFocus(event)"
>.<input name="broadCastIpTwo" MAXLENGTH=3
onkeydown="nextFocus(event)" >.<input name="broadCastIpThree"
MAXLENGTH=3 onkeydown="nextFocus(event)" >.<input
name="broadCastIpFour" MAXLENGTH=3 onkeydown="nextFocus(event)" >
</span>
<script>
function nextFocus(event){
if(event.keyCode==110 || event.keyCode==46 || event.keyCode==190){
event.keyCode=9;
}
}
</script>
*/
this.ipCheck = function(ip){
if(this.isEmpty(email))return true;
var ipArray = ip.split(".");
return
ipCk.test(ip) && new Number(ipArray[0])<=255 && new
Number(ipArray[1])<=255 && new Number(ipArray[2])<=255
&& new Number(ipArray[3])<=255;
}
this.numberOnly = function (str){
if(this.isEmpty(email))return true;
return numberCk.test(str);
}
this.limit = function (len,min,max){
min = min || 0;
max = max || Number.MAX_VALUE;
return min <= len && len <= max;
}
this.isRepeat = function (one,two){
return one==two;
}
this.checkemail = function (email){
if(this.isEmpty(email))return true;
var emailCk = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
if (!emailCk.test(email)) return false;
return true;
}
this.checkmobile = function (mobile){
if(this.isEmpty(email))return true;
var mobileCk = /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!mobileCk.test(mobile)) return false;
return true;
}
this.isEmpty = function (obj){
return (obj=="" || obj.split(" ").join("") == "")?true:false;
}
}
/*引入方式(star)
<script type="text/javascript">
function _import(className){
window.document.write("<scr"+"ipt
type=\"text/javascript\"
src=\"前段路径\""+className+".js\"></sc"+"ript>");
}
_import("AspirinCheck");
</script>
*/