| function IsNumber(obj) { |
| if( typeof(obj) === 'string' ) |
| { |
| var r = /^-?\d+$/; |
| return r.test(obj); |
| } |
| if(typeof(obj) === "number") |
| { |
| if(obj.toString().indexOf(".") != -1) |
| return false; |
| else |
| return true; |
| } |
| return false; |
| } |
| |
| function textBoxMinLength(control,value) { |
| if(document.getElementById(control).value.length < value) |
| return false; |
| else |
| return true; |
| } |
| function IsChineseChar(value) { |
| if(/.*[\u0100-\uffff]+.*$/.test(value)) |
| { |
| return true; |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| function textBoxMaxLength(control,value) { |
| if(document.getElementById(control).value.length > value) |
| return false; |
| else |
| return true; |
| } |
| |
| function textBoxLength(control,value) { |
| if(document.getElementById(control).value.length == value) |
| return true; |
| else |
| return false; |
| } |
| |
| function IsEmail(emailAddr) { |
| var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; |
| if (pattern.test(emailAddr)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsPhoneNumber(phoneNumber) { |
| var pattern = /(^[0-9]{3,4}\-[0-9]{3,15}$)|(^\+?[0-9]{3,20}$)|(^\([0-9]{3,4}\)[0-9]{3,15}$)/; |
| if (pattern.test(phoneNumber)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| |
| function isChineseChar(value) { |
| if(/.*[\u0100-\uffff]+.*$/.test(value)) |
| { |
| return true; |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| function deviceNameValidation(str) { |
| if (isChineseChar(str)) { |
| return false; } |
| |
| if (str.toString().indexOf("#") != -1) |
| return false; |
| else if (str.toString().indexOf(":") != -1) |
| return false; |
| else if (str.toString().indexOf(" ") != -1) |
| return false; |
| else if (str.toString().indexOf("&") != -1) |
| return false; |
| else if (str.toString().indexOf(";") != -1) |
| return false; |
| else if (str.toString().indexOf("~") != -1) |
| return false; |
| else if (str.toString().indexOf("|") != -1) |
| return false; |
| else if (str.toString().indexOf("<") != -1) |
| return false; |
| else if (str.toString().indexOf(">") != -1) |
| return false; |
| else if (str.toString().indexOf("$") != -1) |
| return false; |
| else if (str.toString().indexOf("%") != -1) |
| return false; |
| else if (str.toString().indexOf("^") != -1) |
| return false; |
| else if (str.toString().indexOf("!") != -1) |
| return false; |
| else if (str.toString().indexOf("@") != -1) |
| return false; |
| else if (str.toString().indexOf(",") != -1) |
| return false; |
| else |
| return true;} |
| |
| function IsIPv6(ipv6Addr) { |
| return ipv6Addr.match(/:/g) != null |
| && ipv6Addr.match(/:/g).length <= 15 |
| && /::/.test(str) |
| ? /^([\da-f]{1,4}(:|::)){1,6}[\da-f]{1,4}$/i.test(str) |
| : /^([\da-f]{1,4}:){15}[\da-f]{1,4}$/i.test(str); |
| } |
| |
| function IsIPv4(ipv4Addr) { |
| var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; |
| return null == ipv4Addr.match(exp) ? false: true; |
| return true; |
| } |
| |
| function IsUrl(strUrl){ |
| var regUrl = /(http\:\/\/)?([\w.]+)(\/[\w- \.\/\?%&=]*)?/gi; |
| if (regUrl.test(strUrl)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsHexStr(str){ |
| pattern = /^[0-9a-fA-F]+$/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsASCIIStr(str){ |
| pattern = /^[\x00-\x7F]+$/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsEnglishLetter(str){ |
| pattern = /[a-zA-Z]+/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsMACAddr(mac) { |
| var regex = /^([0-9a-f]{2}([:-]|$)){6}$|([0-9a-f]{4}([.]|$)){3}$/i; |
| if (!regex.test(mac)) |
| return false; |
| else |
| return true; |
| } |
| |
| //time format: hh:mm:ss |
| function IsTime(time) { |
| var regex = /^([0-1]?\d{1}|2[0-3]):[0-5]?\d{1}:([0-5]?\d{1})$/; |
| if (!regex.test(time)) |
| return false; |
| else |
| return true; |
| } |
| |
| //time format: hh:mm |
| function IsTimeEx(time) { |
| //var regex = /^(([0-1]\d)|(2[0-4])):[0-5]\d$/; |
| var regex =/^([0-1]{1}\d|2[0-3]):([0-5]\d)$/; |
| if (!regex.test(time)) |
| return false; |
| else |
| return true; |
| } |
| |
| //date format: yyyy-mm-dd |
| function IsData(date) { |
| var regex = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/; |
| if (!regex.test(date)) |
| return false; |
| else |
| return true; |
| } |
| |
| //port format: xxxx:yyyy |
| function IsPort(port){ |
| var portArr = port.split(":"); |
| for(var idx = 0; idx < 2; ++idx){ |
| if("" == portArr[idx]) |
| return false; |
| |
| if(portArr[idx]>65535 || portArr[idx] < 0) |
| return false; |
| } |
| if(portArr[0] > portArr[1]) |
| return false; |
| |
| return true; |
| } |
| |
| function IsRuleName(ruleName){ |
| if("" == ruleName) return false; |
| if(!IsASCIIStr(ruleName)) return false; |
| |
| return true; |
| } |
| |
| function validate_pin(pin) { |
| var ret = true; |
| |
| if(pin.length < 4 || pin.length > 8) |
| ret = false; |
| |
| if(!IsNumber(pin)) |
| ret = false; |
| |
| return ret; |
| } |
| |
| function validate_puk(puk) { |
| var ret = true; |
| |
| if(puk.length < 4 || puk.length > 10) |
| ret = false; |
| |
| if (/\W/.test(puk)) |
| ret = false; |
| |
| return ret; |
| } |
| |