View Full Version : Validating entries in a form

03-20-2006, 10:30 PM

I'm having a little trouble if you guys could help I've be very grateful. I need some type of validation code that will check whether a user types in the same thing in two seperate fields in a form, for example, when your asked to type your password in twice when registering. Also is there a way that I can have invalid text/symbols in certain fields in the form.

Thanks again. Much appreciated.


03-21-2006, 02:13 AM
Are you using php? You can do it by comparing strings in the form.

03-21-2006, 07:56 AM
you can do this using javascript or a scripting language

if your just checking if 2 strings match for password validation then i would go down the javascript route

change your submit button to a plain button and add...

<input type="button" name="Button" value="Button" onclick="passwordcheck()" />

here is your function....

function passwordcheck(){

a = document.getElementById('field1'); //set var to field1
b = document.getElementById('field2'); //set var to field2

If(a.value == b.value){

else {

alert('you password needs to match in both fields');



03-21-2006, 10:03 AM
Thanks for your replies guys. I'm using javascript, Derek - I've never tried php - but again thanks for your help!

change your submit button to a plain button and add...

The button I have validates other things in the form, is there any other way around this?