Solved

change password validation in struts jsp

Posted on 2008-10-02
3
3,392 Views
Last Modified: 2013-11-24
Hi, I have created one jsp in struts framework to change the user's current password. There are three fields in my jsp, enter current password , enter new password and confirm your new password. I want the code to check the new password and the old password and then pass the new password. also i want to check whether the new password and the confirm new password is maching or not. I want to do the client side validation using javascript. Can you please help me in this.
0
Comment
Question by:yashjimmy
3 Comments
 
LVL 1

Accepted Solution

by:
Manoj_Pardeshi earned 250 total points
ID: 22740471
Use javascript to check whether the new password and confirm password are matching. Then after submiting the form , in action check the database if the old password is corrct or not . If it is incorrect show error message.
0
 
LVL 6

Assisted Solution

by:javaexperto
javaexperto earned 250 total points
ID: 22746879
You can check the new password and the confirm password with this javascript function:
where the pass and newpass are the names of the textfields for example:
<input type="password" name="pass" value="">
<input type="password" name="newpass" value="">
Remember to put these inside a form and call the validate function like this:
<form name="mainform"  action="/changePass.do" target="blank" method="post" onSubmit="validate();">

In order to check the old password you need to call your action and then get the text field value. Another approach is with Ajax if you dont want to reload the entire page, here is a short tutorial:
http://www.w3schools.com/Ajax/Default.Asp


function validate() {
    pass=mainform.pass.value;
    newpass=mainform.newpass.value;
    if (pass!=newpass) {
        alert('the new pass doesn't match with the confirm');
        event.returnValue=false;
    }
}

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question