在逐浪CMS中,经常会遇到自由字段增加功能。这也是逐浪CMS的强大特色,比如注册页加字段:
如果加了这段,如何定义其正则呢?
其实很简单,只要编辑
Areas\User\Views\Index\Register.cshtml
文件
加上你的字段正则就行,如下:
validate.zl_init($("form"), { rules: { TxtUserName: { required: true }, TxtPassword: { required: true }, TxtPwdConfirm: { required: true, equalTo: "#TxtPassword" }, userType: { required: true }, userTypeTest: { required: true }, userTypeTwoTest: {exec:/[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}/g}, selcoutry: { required: true } /照此加字段 }, messages: { TxtUserName: { required: "用户名不能为空" }, TxtPassword: { required: "密码不能为空" }, TxtPwdConfirm: { required: "确认密码不能为空", equalTo: "必须同于密码" }, userType: { required: "身份不能为空" }, userTypTest: { required: "身份内容不能为空" }, userTypeTwoTest: { exec: "统一社会信用代码格式错误" }, selcoutry: { required: "省市县选择不能为空" } //照此加字段 },