Home Answers Viewqa JavaScriptQuestions Password validation

 
 


Sujitha
Password validation
1 Answer(s)      10 months ago
Posted in : JavaScript Questions

Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.

View Answers

August 16, 2012 at 3:44 PM


Here is a code that accepts the current password, New password and conform password from the user and change the password.

1)change.jsp

<html>
<script>
function validate(){
if(document.f.new.value!=document.f.confirm.value){
alert("New Password and Confirm Password should be same! Re-enter confirm-password!");
document.f.confirm.value="";
return false;
}
return true;
}
</script>
<form name="f" action="changePassword.jsp" method="post" onsubmit="return validate();">
<table>
<tr><td>Current Password</td><td><input type="password" name="current" ></td></tr>
<tr><td>New Password</td><td><input type="password" name="new"></td></tr>
<tr><td>Confirm Password</td><td><input type="password" name="confirm"></td></tr>
<tr><td><input type="submit" value="Change Password"></td></tr>
</table>
</form>
</html>

2)changePassword.jsp

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%
String currentPassword=request.getParameter("current");
String Newpass=request.getParameter("new");
String conpass=request.getParameter("confirm");
String connectionURL = "jdbc:mysql://localhost:3306/test";
Connection con=null;
String pass="";
int id=0;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from login where password='"+currentPassword+"'");
if(rs.next()){
id=rs.getInt(1);
pass=rs.getString(3);
}
System.out.println(id+ " "+pass);
if(pass.equals(currentPassword)){
Statement st1=con.createStatement();
int i=st1.executeUpdate("update login set password='"+Newpass+"' where id='"+id+"'");
out.println("Password changed successfully");
st1.close();
con.close();
}
else{
out.println("Invalid Current Password");
}
}
catch(Exception e){
out.println(e);
}
%>









Related Pages:
Password validation
password and confirm password are same or not Validation  Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.   Here
Password validation
Password validation  Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.   Here is a code that accepts the current password
Password validation
Password validation  Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.   Here is a code that accepts the current password
Password validation
Password validation  Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.   Here is a code that accepts the current password
Password validation
Password validation  Hi. I have a change password form. In that i have to check the values given in the new password and confirm password are same or not. Please help.   Here is a code that accepts the current password
password validation with special character
password validation with special character  how to validate password with special character using java script
validation
validation  How to validate username and password in a login screen
Login Password Validation iPhone / iPAD
Login Password Validation iPhone / iPAD  HOW TO WRITE A TEST CASE TO SET THE VALIDATION FOR LOGIN AND PASSWORD FIELD IN OBJECTIVE C, IOS.   @implementation LoginViewTests - (void)testPasswordFieldIsNotEmpty
validation
;</td> </tr> <tr> <td>Password :</td> <td><form:password path="password" /><...; private String name; private String password; private String gender
Validation
; <b>Password</b> :<input type="Password
Validation
; <b>Password</b> :<input type="Password
jQuery password validation
jQuery password Validation : jQuery "equalTo: "#password" " is the method to validate or check password if the element is empty (text input... validation we can check that password and verify password are equal.   
Username password
with the validation, so that if the username and password match it will continue... that checks whether the username and password is valid or not. If the user...("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("SUBMIT
String Validation
String Validation changing password  Hi. I have a HTML coding in that I have to check whether the value given in the 2 password fields are same or not. Its for the form changing password. If they are not same it should give
String Validation
String password Validation  Hi. I have a HTML coding in that I have to check whether the value given in the 2 password fields are same or not. Its for the form changing password. If they are not same it should give a message
form validation
want validation code,username minimum 8 char,password length must >6,and one...; <tr><td>password:</td><td><input type="password" name="password" /></td></tr> <tr><
String Validation
whether the value given in the 2 password fields are same or not. Its for the form changing password. If they are not same it should give a message.   Here is a code that accepts the current password, New password and conform
String Validation
whether the value given in the 2 password fields are same or not. Its for the form changing password. If they are not same it should give a message.   Here is a code that accepts the current password, New password and conform
user validation
page if username & password is invalid but it does redirect only if the username is valid and password invalid.i want know wer i am going wrong...{ out.println("Please enter correct username and password"); out.println
Password
Password  make a program which ask ask the username and password * in this format. in C language
Custom Form Validation - PHP
Custom Form Validation  Which is the best way or where should I implement the custom validation rules such as ? using number, capital letters and symbols to secure the password
Developing Forgot Password Form
Developing Forgot Password Form       In this section we will develop Forgot Password Form code for our application. Developing Forgot Password Form  
HTML Form Validation example
HTML Form Validation example  Can anyone guide me how to validate the user name and password field in HTML using simple or JavaScript Validation. Thanks in advance!   <form method="post" onsubmit="return
validation
validation  validation
Login page validation on ipad
Login page validation on ipad  I am using userId & password labels and their corresponding textfield. Now I want to validate the details... to display message "invalid UserId" & "invalid password" Can u forword me
STRUTS2.0 Validation Errors
STRUTS2.0 Validation Errors   <!DOCTYPE validators PUBLIC...;field name="password"> <field-validator type="requiredstring">...;Password is required</message> </field-validator> </field>
jsp-oracle validation - JDBC
jsp-oracle validation  Dear friends, my validation not takes place...: Password... database SQL> select * from login; USERID PASSWORD
Login validation doubt
Login validation doubt  Hi, 1)login.jsp: <%@page import="java.sql.*"%> Username: Password: 2)check.jsp: <% String user... 'username or password is not provided' if username or password is null. How get
login page validation
validations Email validation and password email should be in correct format and valid password in java   import java.awt.*; import javax.swing....:"); t1=new JTextField(20); l2=new JLabel("Enter Password: "); t2=new
validation web page
validation web page  vivek i want to crate a webpage with specfic email id and password to that webpage . using jsp & servlets   Hi...; if(pass.length<6){ alert('Password should be of atleast 6 characters
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
validation problem in struts - Struts
validation problem in struts  hi friends... m working on one... mean i hav 4 username and 4 password in d database nd whn m reteriveing all d username nd password in a string only d last values in database is coming in d
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
validation - Java Beginners
JavaScript validation file 'validation.js': function emailcheck(str... ( "Please enter password." ); document.userform.password.focus... password." ); document.userform.password.focus(); return false
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter only numerical values in textbox , if he enters string values then it should
Struts 2 Validation
, password varchar(20) not null, email varchar(40) not null, category varcahr... username and password for mysql
change password servlets - JSP-Interview Questions
for the confirm password. You also have validation for these text boxes (ex. should...change password servlets  hi all, i need the codes to create a change password servlet.  Hi, I dont have the time to write the code. But i
Java User Validation
user in the database and add encrypted password(Please provide a java program
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put
validation - Swing AWT
validate a registration form through swings..fields like user,password,email... = new JTextField(20); label4 = new JLabel(); label4.setText("Password... Password"); } else if(f5==false
JSP data base validation
= "jdbc:mysql://localhost:3306/record"; String user = "root"; String password... = DriverManager.getConnection(url, user, password); ps1
Validation
); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class="col1"> <label>Sno:</label> </td> <td
stuts java script validation is not working.
stuts java script validation is not working.  hello my stuts client side validation is not working. pls help me out i have put jsp file's code...;/field> <field property="password" depends
validation using validator-rules.xml - Struts
validation using validator-rules.xml  Hi I am trying to validate my... --------------------------------------------------------------------------- Name Password... String name=""; private String password=""; public String getName() { return