Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

real time form validation and DHTML

Status
Not open for further replies.

NickyJay

Programmer
Sep 1, 2003
217
GB
Hi all,

can anyone point me in the right direction? I've been searching all day with no luck!

I have to validate 3 inputs on a form and change how the inputs are displayed if they are incorrect according to my javascript functions. I have posted this in the html/css forum also :)

Thanks!
 
Shouldn't double post, that's a no-no.

You should probably call your functions on the onsubmit attribute on the form


<form onsubmit="return functionName()">

If the inputs are "incorrect", don't validate, then alert as to what needs to be changed and return false from the function.

This will work in the case that you have a submit button.

If you submit the form with Javascript, then you must first call the validation function and there is no need for the onsubmit attribute.

[monkey][snake] <.
 
Hi!

Thanks for responding - sorry but i had to double post as i didnt know where to post!

I already have an onSubmit, but i need to have on three seperate fields also, need to be able to either change the field background/text colour but not thow an alert box...

Thanks
 
Ok, just check each of your fields in your validation function.

If you have something that is invalid in a text field, change the background color and foreground color.

I'm not sure, without seeing what code you have, exactly what your question is.






[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top