views:

46

answers:

2

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

+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:

http://www.willmaster.com/library/manage-forms/ensuring-two-form-fields-have-identical-information.php

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
bingo! Could also consider using the `ChangePassword` control
Russ Cam
want javascript for validate them
Sikender
+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