我正在使用meteor来开发我的应用程序。我需要验证我的注册表单,以便限制用户。现在,我在我的注册表单中有密码和确认密码。我正在使用正则表达式进行验证。
我的代码是:
Template.signup.rendered = function() {
$("#signup").validate({
rules: {
name: {
required: true,
pattern:/^[A-Za-z ]{0,20}$/
},
age: {
required: true,
pattern:/^[0-9]{0,3}$/
},
disease: {
required: true,
pattern:/^[A-Za-z ]{0,30}$/
},
city: {
required: true,
pattern:/^[A-Za-z ]{0,20}$/
},
email: {
required: true,
pattern:/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
},
pass: {
required:true,
pattern: /^[A-Za-z0-9!@#$%^&*_]{6,20}$/
},
c_pass: {
required:true,
pattern: $("#pass").val();
},
messages: {
name: {
required: "Enter Name",
pattern : "Only alphabets"
},
age:{
required: "Enter age",
pattern : "Only digits and length should be 2"
},
disease:{
required: "This field is required",
pattern : "Only alphabets"
},
city: {
required: "This field is required",
pattern : "Only alphabets allowed"
},
email: {
required: "Please Enter an Email",
pattern : "Please Enter a valid email address"
},
pass: {
required: "Please enter password",
pattern: "Password should be 6 or more"
},
c_pass: {
required: "Enter Confirm Password",
pattern: "Password does not match"
}
});
}
现在,我需要某种代码,以便我可以比较渲染中的确认密码和密码以及使用正则表达式或其他内容。