jquery - How to validate old password when i change a new password -


I have a form to edit a user account, where I give a new password and old password in the input field. If the new password field is not filled, the data will be stored, and if I need to fill in the old password field filled in the new password field, how do I provide verification? The new password is not equal to the old password.

Here's my code:

  & lt; Div class = "form-group" & gt; & Lt; Label class = "control-label" & gt; Current Password & lt; / Label & gt; & Lt; Input type = "password" name = "currentPassword" class = "form-control" & gt; & Lt; / Div & gt; & Lt; div class = "form-group" & gt; & Lt; Label class = "control-label" & gt; New password & lt; / Labels & gt; & Lt; Input type = "password" name = "newpassword" id = "newpassword" class = "form-control" & gt; & Lt; / Div & gt;   

Any suggestions?

  Keeping HTML in mind, there is something like this: - & lt; Div class = "form-group" & gt; & Lt; Label class = "control-label" & gt; Current Password & lt; / Label & gt; & Lt; Input id = "oldpassword" type = "password" name = "current password" class = "form-control" & gt; & Lt; / Div & gt; & Lt; div class = "form-group" & gt; & Lt; Label class = "control-label" & gt; New password & lt; / Label & gt; & Lt; Input type = "password" name = "newpassword" id = "newpassword" class = "form-control" & gt; & Lt; / Div & gt; Javascript code: - if ($ .trim ($ ('# newpassword'). Val ())! = "" & Amp; $ .trim ($ old password). Val ()) == "") { return false; // display error message} and if ($ .trim ($ ('$ newpassword'). Val ())! = "" & Amp; $ .trim ($ (# old password '). Val ())! = "") {If ($ .trim ($ ('$ newpassword'). Val ())! = $ .trim ($ (# old 'code' here 'powered'). Val ()) {// Show error Message that does not match password}}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -