Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

change password validation in struts jsp

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Books that can get me started on JAVA 2 104
Core Java. What output will be and why ? 6 67
eclipse java  build path 6 63
replace a word with other 1 45
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…
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.

792 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