正則表達(dá)式
/*********************************
* Themes, rules, and i18n support
* Locale: Chinese; 中文
*********************************/
(function (factory) {
if (typeof define === 'function') {
define(function (require, exports, module) {
var $ = require('jquery');
$._VALIDATOR_URI = module.uri;
require('../src/jquery.validator')($);
factory($);
});
} else {
factory(jQuery);
}
}(function ($) {
/* Global configuration
*/
$.validator.config({
//stopOnError: false,
//theme: 'yellow_right',
defaultMsg: "{0}格式不正確",
loadingMsg: "正在驗(yàn)證...",
// Custom rules
rules: {
digits: [/^\d+$/, "請(qǐng)輸入數(shù)字"],
recomTag: [/^[A-Za-z0-9]+$/, "請(qǐng)輸入數(shù)字或字母"],
recomAmount: [/^[1-9]|[1-9]\d+$/, "請(qǐng)輸入數(shù)字,不能為0"],
letters: [/^[a-z]+$/i, "{0}只能輸入字母"],
tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "電話格式不正確"],
mobile: [/^1[3-9]\d{9}$/, "手機(jī)號(hào)格式不正確", "請(qǐng)輸入正確格式的手機(jī)號(hào)"],
email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "郵箱格式不正確", "請(qǐng)輸入正確格式的郵箱"],
qq: [/^[1-9]\d{4,}$/, "QQ號(hào)格式不正確"],
date: [/^\d{4}-\d{1,2}-\d{1,2}$/, "請(qǐng)輸入正確的日期,例:yyyy-mm-dd"],
time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "請(qǐng)輸入正確的時(shí)間,例:14:30或14:30:00"],
time1: [/^([01]{0,1}\d|2[0-3])(:[0-5]\d){1,2}$/, "時(shí)間格式:14:30"],
ID_card: [/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Z])$/, "請(qǐng)輸入正確的身份證號(hào)碼"],
url3: [/^((http:\/\/)|(https:\/\/))?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9]{2,6}(:[0-9]+)?$/i, "請(qǐng)輸入正確格式的網(wǎng)址"],
url: [/^(https?|ftp|http):\/\/[^\s]+$/i, "請(qǐng)輸入正確格式的網(wǎng)址"],
url5: [/^(https|ftp|http):\/\/.+$/i, "請(qǐng)輸入正確格式的網(wǎng)址"],
url2: [/^((http:\/\/)|(https:\/\/))?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/i, "請(qǐng)輸入正確格式的網(wǎng)址"],
url1: [/^(https?|ftp|http):\/\/[^\s]+|([a-zA-Z\d][a-zA-Z\d-_]+\.)+[a-zA-Z\d-_][^ ]*$/, "請(qǐng)輸入正確的域名"],
url4: [/^((http:\/\/)|(https:\/\/))?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+(cn|cx|co|cn|wang|cc|xin|com|net|top|tech|org|red|pub|ink|info|xyz|win|edu|[0-9]{2,6})(:[0-9]{1,6})?([\/]\S*)*$/, '請(qǐng)輸入正確格式的網(wǎng)址'],
postcode: [/^[1-9]\d{5}$/, "郵政編碼格式不正確"],
positive: [/^\d+(.\d{1,2})?$/, "請(qǐng)輸入正數(shù)"],