I'm currently building C # applications with MVC, a very simple registration form, where the user has other things besides Username and password are required to be filled. I want to apply a client-side verification that checks whether the given password is sufficient or not, I already have a check in the set of models, but it only checks when the submit button is pressed and thus Information is lost.
This is a simplified version of my check method:
The public is stable but this password (string pw) {int score = 0; // PW Length is 8 + (PW Langan & lt; 8) Return false; And come back to the truth; // There is a check in whether it has lowercase, upper case letter, a number and a special character. That bit was omitted}
I had already found the basics of a class, I think I need it, although I do not understand how it is Finish and implement it. Any help will be very much appreciated!
Are you aware of RemoteAttribute
?
This feature takes an 'ActionMethod' and 'Controller' as a string parameter. By returning the JSON results, it will be called automatically if you use the jquery.validation package / script.
The attribute can be used like this:
[remote ("valid password", "account")] public string NewPassword {get; Set; } and account controller
may look like this in:
[authorized] public async Work & lt; JsonResult & gt; Valid passwords (string newpowword) {var results awaiting this. DoSomeValidationOfPassword (NewPassword); If (the result) {This return. Jason (True, Jesuit Behavior, Elove Gate); } Other {return it. Jason ("Passwords have the following demands: \ r \ n" + String .Join ("\ r \ n", results. Errors, allowJasonFest Behavior.); }}
In your view, you can use a normal validation message
html attribute:
@ Html.PasswordFor (M = & gt; m.NewPassword, new {@class = "form-control"}) @ html.ValidationMessageFor (m = & gt; m.NewPassword, "", new {@class = "text-danger"} )
jquery.validate.js
Make sure to include the script!
No comments:
Post a Comment