Solved

change password validation in struts jsp

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
either24  challenge 19 84
sameEnds challenge 25 71
abstract class with all non abstract mentods 6 71
countPairs challenge 7 58
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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.

708 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

16 Experts available now in Live!

Get 1:1 Help Now