<script>
/**
* 校驗輸入的 ip 字符串
*
* @param ip
* @return boolean
*/
function checkIp(s){
var patrn=/^(\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])$/;
alert(patrn.test(s));
/**
* 校驗輸入的 ip 字符串
*
* @param ip
* @return boolean
*/
function checkIp(s){
var patrn=/^(\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])$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 email 字符串
*
* @param email
* @return boolean
*/
function checkEmail(s){
var patrn=/^[a-zA-Z_][a-zA-Z0-9_]*@[a-zA-Z0-9]*\.[a-zA-Z]*(\.[a-zA-Z]*){0,2}$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 url 字符串,且URL不區分大小寫.
*
* @param url =[http://][https://][ftp://]www.zz.ha.cn:80
* @return boolean
*/
function checkUrl(s){
var patrn=/^((http|https|ftp):)?(\w+\.)((\+\.){0,3})\w+(:[1-9]\d{1,5})?(\w*)$/;
alert(patrn.test(s));
* 校驗輸入的 url 字符串,且URL不區分大小寫.
*
* @param url =[http://][https://][ftp://]www.zz.ha.cn:80
* @return boolean
*/
function checkUrl(s){
var patrn=/^((http|https|ftp):)?(\w+\.)((\+\.){0,3})\w+(:[1-9]\d{1,5})?(\w*)$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 strDate 字符串
*
* @param strDate 月/日/年
* @return boolean
*/
function checkDate1(s){
var patrn=/^(\d{2}|\d{4})-((0?([1-9]{1}))|(1[1|2]))-(([0-2]?([1-9]{1}))|(3[0|1]))$/;
alert(patrn.test(s));
/**
* 校驗輸入的 strDate 字符串
*
* @param strDate 月/日/年
* @return boolean
*/
function checkDate1(s){
var patrn=/^(\d{2}|\d{4})-((0?([1-9]{1}))|(1[1|2]))-(([0-2]?([1-9]{1}))|(3[0|1]))$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 strDate 字符串
*
* @param strDate 月/日/年
* @return boolean
*/
function checkDate2(s){
var patrn=/^((0?([1-9]{1}))|(1[1|2]))\/(([0-2]?([1-9]{1}))|(3[0|1]))\/(\d{2}|\d{4})$/;
alert(patrn.test(s));
/**
* 校驗輸入的 strDate 字符串
*
* @param strDate 月/日/年
* @return boolean
*/
function checkDate2(s){
var patrn=/^((0?([1-9]{1}))|(1[1|2]))\/(([0-2]?([1-9]{1}))|(3[0|1]))\/(\d{2}|\d{4})$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 phoneNum 字符串
*
* @param phoneNum =[0371-]63025811 [010-]66666666
* @return boolean
*/
function checkPhoneNum(s){
var patrn=/^(0?\d{2,3}-)?\d{7,8}$/;
alert(patrn.test(s));
* 校驗輸入的 phoneNum 字符串
*
* @param phoneNum =[0371-]63025811 [010-]66666666
* @return boolean
*/
function checkPhoneNum(s){
var patrn=/^(0?\d{2,3}-)?\d{7,8}$/;
alert(patrn.test(s));
}
/**
* 校驗輸入的 userName 字符串
* 帳號是否合法(字母開頭,允許5-16字節,允許字母數字下劃線
*
* @param userName = 字母開頭,允許5-16字節,允許字母數字下劃線
* @return boolean
*/
function checkUserName(s){
var patrn=/^[a-zA-Z_][a-zA-Z_0-9]{4,15}$/;
alert(patrn.test(s));
* 校驗輸入的 userName 字符串
* 帳號是否合法(字母開頭,允許5-16字節,允許字母數字下劃線
*
* @param userName = 字母開頭,允許5-16字節,允許字母數字下劃線
* @return boolean
*/
function checkUserName(s){
var patrn=/^[a-zA-Z_][a-zA-Z_0-9]{4,15}$/;
alert(patrn.test(s));
}
</script>
</script>