Home Answers Viewqa JavaScriptQuestions String Validation changing password

 
 


Sujitha
String Validation changing password
1 Answer(s)      9 months ago
Posted in : JavaScript Questions

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.

View Answers

August 16, 2012 at 3:42 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:
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
String Validation
String 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.   
String Validation
String 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.   
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
Changing root Password
Changing root Password  how do i change the root password in mysql
validation
; private String name; private String password; private String gender...;</td> </tr> <tr> <td>Password :</td> <td><form:password path="password" /><
MySQL Creating account and changing password
MySQL Creating account and changing password   ...; password to same random to be string . the better way is to change the login... or  you want to change the password then make new user .This lesson you learn how
password validation with special character
password validation with special character  how to validate password with special character using java script
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
validation
validation  How to validate username and password in a login screen
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
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
; static DefaultTableModel model; public static void main(String[] args) { String...(); String columnName = table.getModel().getColumnName(0); headerRenderer.setText...); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel
Validation
; <b>Password</b> :<input type="Password
Validation
; <b>Password</b> :<input type="Password
Validation
actionPerformed(ActionEvent ae){ String value1=text1.getText(); String value2...(Exception e){} } }); } } class FormDemo{ public static void main(String arg
string validation in php - PHP
string validation in php  Can you please post a example of PHP Built-in String Validation Functions
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... ServletException,IOException{ String userlog = request.getParameter("textfield
how to reverse a string without changing its place
how to reverse a string without changing its place  how to reverse a string without changing its place   Hi Friend, Another way of reversing string: import java.util.*; public class ReverseString{ public static
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.   
changing the file content
changing the file content  I have requirement like this, a file contain maximum 1000 lines. I want to cahnage the 501 line content. I know this logic... more file and storing this changeing information String line=null; String
Login validation doubt
Login validation doubt  Hi, 1)login.jsp: <%@page import="java.sql.*"%> Username: Password: 2)check.jsp: <% String user=request.getParameter("user"); String pass=request.getParameter("pass"); if(user.equals
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 problem in struts - Struts
username nd password in a string only d last values in database is coming in d... = af.getUsername(); String password = af.getUserpassword(); String...validation problem in struts  hi friends... m working on one
color changing - Java Beginners
*; public class CreateTabbedPane{ public static void main(String[] args
change password servlets - JSP-Interview Questions
for the confirm password. You also have validation for these text boxes (ex. should...:3306/test"; String username = "root"; String password = "root"; String query... void showTable(String driver, String url, String username, String password, String
password - Security
password  How can i do password encript and decript in java  Hi friend, Code to encript and decript password in java import... { public static void main(String[] args) throws Exception{ String
validation - Swing AWT
validate a registration form through swings..fields like user,password,email... = new JTextField(20); label4 = new JLabel(); label4.setText("Password...(ActionEvent ae){ String value1=text1.getText(); String value2=text2.getText
JSP data base validation
;/table> </form> <% String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/record"; String user = "root"; String password... string with database n also how its notify that entered data exists already
validation using validator-rules.xml - Struts
String name=""; private String password=""; public String getName() { return...; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password
changing Background Color
changing Background Color       In this program, we are going to tell you how you can...;{  public static void main(String[] args)throws 
Mandatory Fields Validation - Java Beginners
= "com.mysql.jdbc.Driver"; String userName = "amar"; String password = "amar123... username and password. I would like a message to be displayed when both or one field... and passoword is name of the password textbox.  Hello, you can do
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
Change root password of MYSQL using Java
of Code: Changing the root password of a MySQL database is trivial if you know...Change root password of MYSQL using Java In this tutorial, you will learn how to change the root password of MYSQL database using java code. For every
struts2.2.1 validation Interceptor example
String userName; private String password; public... password; } public void setPassword(String password) { this.password = password; } public String
struts2.2.1 Login validation example.
userName; private String password; public String...; } public String getPassword() { return password; } public void setPassword(String password
change password - JSP-Servlet
for a user. this web page consists of changing the password for the existing user. it look like this: current password new password confirm new password SUBMIT(a submit button) now this current password is already in the database named
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try to put string values its not allowing to do tht it gives us message its right
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><
Jdbc Login Page Validation using Combobox
= request.getParameter("username"); String password = request.getParameter("password...(); String query = "select uname,password from dblogin where uname='"+name...Jdbc Login Page Validation using Combobox  I got Login By this code i
Jdbc Login Page Validation using Combobox
(); String name = request.getParameter("username"); String password = request.getParameter("password"); try{ String driver = "org.postgresql.Driver...=con.createStatement(); String query = "select uname,password from dblogin where uname
Jdbc Login Page Validation using Combobox
(); String name = request.getParameter("username"); String password = request.getParameter("password"); try{ String driver = "org.postgresql.Driver...=con.createStatement(); String query = "select uname,password from dblogin where uname
Example of struts2.2.1 client side validation.
firstname; private String password; public String getFirstname... password; } public void setPassword(String password) { this.password...Example of struts2.2.1 client side validation. In this example, you will see
Password encryption and decryption
name=request.getParameter("name"); String password=request.getParameter("pass...(); cipher = Cipher.getInstance(algorithm); String input = password... where id='1'"); String str=""; if(rs.next()){ str=rs.getString("password
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box...; var password=document.form.pass.value; if(username==""){ alert("Enter Username

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.