I have a project in which I have to add a registration form and I want to to validate that the password and confirm fields are equal without clicking the register button.
The code proposed by #Chandrahasa Rai works almost perfectly good, with one exception!
When triggering function checkPass(), i changed onkeypress to onkeyup so the last key pressed can be processed too. Otherwise when You type a password, for example: "1234", when You type the last key "4", the script triggers checkPass() before processing "4", so it actually checks "123" instead of "1234". You have to give it a chance by letting key go up :)
Now everything should be working fine!
#Chandrahasa Rai, HTML code:
#my modification: