I have a jQuery code which going to match passwords from text fields which taken from here . But its not completed. Can any one help me with how to match the password from textfields by this code? Thanks.
Here is my jQuery code segment for password matching. I need to have the logic for "none" part I think.
{
"confirm": { // password matching
"regex": "none",
"alertText": "* Your field is not matching"
},
"telephone": {
"regex": "/^[0-9\-\(\)\ ]+$/",
"alertText": "* Invalid phone number"
},
"email": { // For email validation
"regex": "/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
"alertText": "* Invalid email address"
}
}
I think in this code the didn't give the matching loginc in "regex":"none"
, part. Can anyone help with this?
In email fields, we will have a @
symbol and .
period in general. So, we will match for both of them.
But, in general we allow all characters in password field. So, there is no any special match REGEX we check for that. The only thing I guess we match for is minimum and maximum characters allowed in the password filed.
For example, if we are expecting 8 to 20 characters password, then use the following.
/.{8,20}/
It seems you are writing a generalized validation engine. At first look, we think that we generally check for any fields value and we simply do that using a regex match. But if we further go into it, we may require following in some cases
or
or and
conditions - it seems you are already doing this and
state in your validate2fields
item ... and some more.
CodeIgniter PHP framework provides a custom form_validation support and they implemented some generally used validations.
You can find the same here , in Rule Reference
Section.
Coming to your point, to match two different fields, you don't need to do any regex match, but you need to provide get the id of other field dynamically in your rules and compare them based on that id.
I suggest, give a type
property for each rule and give one of options like
regex
- which matches with regex field
- which checks with other field. Give an operator
option, which will check for different options. Hope this gives an idea on what you want to achieve.
Friends, please suggest any better solutions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.