ElegantWM.WebUI/Application/common/src/Tools.js
欢迎大家贡献更多的正则验证规则,目前支持如下:
/*****************************************************************/ /* VType自定义校验 */ /*****************************************************************/ Ext.apply(Ext.form.VTypes, { number: function (val, field) { return /^\d+$/.test(val); }, numberText: ‘只能输入数字‘, mobilephone: function (val, field) { return /^1[3|4|5|6|7|8|9][0-9]{1}[0-9]{8}$/.test(val); }, mobilephoneText: ‘手机号码格式错误‘, postcode: function (val, field) { return /^[1-9]\d{5}$/.test(val); }, postcodeText: ‘邮政编码格式错误‘, idnum: function (val, field) { return /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test(val); }, idnumText: ‘身份证格式错误‘, ipaddress: function (val, field) { return /^(\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])$/.test(val); }, ipaddressText: ‘IP地址格式错误‘, amount: function (val, field) { return /^(([1-9]\d*)|\d)(\.\d{1,2})?$/.test(val); }, amountText: ‘金额格式错误‘, passwordConfirm: function (value, field) { if (!(field.confirmTo instanceof Ext.form.Field)) { field.confirmTo = Ext.getCmp(field.confirmTo); } return (value == field.confirmTo.getValue()); }, passwordConfirmText: ‘两次新密码输入不一致‘ });