String password 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.

View Answers

August 16, 2012 at 3:41 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 Tutorials/Questions & Answers:
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
Advertisements
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
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
password validation with special character
password validation with special character  how to validate password with special character using java script
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.   
string validation in php - PHP
string validation in php  Can you please post a example of PHP Built-in String Validation Functions
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
ModuleNotFoundError: No module named 'django-advanced-password-validation'
ModuleNotFoundError: No module named 'django-advanced-password-validation' ...: ModuleNotFoundError: No module named 'django-advanced-password-validation' How to remove... to install padas library. You can install django-advanced-password-validation
ModuleNotFoundError: No module named 'django-password-validation'
ModuleNotFoundError: No module named 'django-password-validation'  Hi...: No module named 'django-password-validation' How to remove the ModuleNotFoundError: No module named 'django-password-validation' error? Thanks
ModuleNotFoundError: No module named 'django-password-validation-backport'
ModuleNotFoundError: No module named 'django-password-validation-backport' ...: ModuleNotFoundError: No module named 'django-password-validation-backport' How to remove the ModuleNotFoundError: No module named 'django-password-validation
ModuleNotFoundError: No module named 'django-advanced-password-validation'
ModuleNotFoundError: No module named 'django-advanced-password-validation' ...: ModuleNotFoundError: No module named 'django-advanced-password-validation' How to remove... to install padas library. You can install django-advanced-password-validation
ModuleNotFoundError: No module named 'django-password-validation'
ModuleNotFoundError: No module named 'django-password-validation'  Hi...: No module named 'django-password-validation' How to remove the ModuleNotFoundError: No module named 'django-password-validation' error? Thanks
ModuleNotFoundError: No module named 'django-password-validation-backport'
ModuleNotFoundError: No module named 'django-password-validation-backport' ...: ModuleNotFoundError: No module named 'django-password-validation-backport' How to remove the ModuleNotFoundError: No module named 'django-password-validation
ModuleNotFoundError: No module named 'fast-password-validation'
ModuleNotFoundError: No module named 'fast-password-validation'  Hi...: No module named 'fast-password-validation' How to remove the ModuleNotFoundError: No module named 'fast-password-validation' error? Thanks  
JavaScript password validation
JavaScript password validation We are going to discuses about JavaScript password special characters validation. In this example we have created one "... used JavaScript password validation and check for an alphabet , number
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.   
Password
Password  make a program which ask ask the username and password * in this format. in C language
validation
validation  validation
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
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  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
validation
; private String name; private String password; private String gender...;</td> </tr> <tr> <td>Password :</td> <td><form:password path="password" /><
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
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
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both... "String args[]" can mean a "string array called args which is an array
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
String
String  how to add spaces with string functions.?   Hi... { public static String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
*; class ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
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
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
forgot password?
forgot password?  forgot password

Ads