Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

change password validation in struts jsp

Posted on 2008-10-02
3
Medium Priority
?
3,540 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 1000 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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 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.
Suggested Courses

927 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