i have two textbox in asp.net and first for password and second is for matching password
.. if user give different value in both textbox , then i want to generate javascript at client side..
views:
46answers:
2
+2
A:
Have you considered the CompareValidator control for this?
It's what the CompareValidator was designed for.
edit - added
If you just want the javascript and want to do it completely in javascript, here's an example:
However, the CompareValidator takes care of generating the javascript for you (as long as client side validation is turned on), so in my opinion (and it IS just an opinion) you're making it harder on yourself by writing the javascript yourself.
David Stratton
2009-11-11 19:50:20
bingo! Could also consider using the `ChangePassword` control
Russ Cam
2009-11-11 19:52:59
want javascript for validate them
Sikender
2009-11-11 19:53:17
+2
A:
The simplest js for this would be
if(document.getElementById('password1').value != document.getElementById('password2').value){
// they do not match
}
But if you are using .NET, you might want to take the advice to use a CompareValidator.
bmoeskau
2009-11-11 20:04:41