Solved

change password validation in struts jsp

Posted on 2008-10-02
3
3,376 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
scoresIncreasing challenge 10 64
stringclean challenge 26 71
custom annotations 9 33
Spring Framework HTTPSession management 1 24
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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…
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now