Need help with JS for web form validation!

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

Hi.

I need help setting up some JavaScript to validate entries in a web form. Nothing too fancy, just have to check for values in certain required fields, require the customer to make a selection from a drop-down menu, etc.

I could probably hack it out but would take some time in trial and error.

So any help would be appreciated!

Thanks! Smiling

dk01's picture

He has: 516 posts

Joined: Mar 2002

This is quite basic but if you really don't feel like figuring it out then check this link out:
http://javascriptkit.com/script/cutindex13.shtml
It has so much validation stuff I didn't even feel like looking through it. Enjoy.
-dk

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

Lots of great stuff there - thanks.

But I was looking for something more customized in terms of mssages. For example, if the person leaves the payment type drop-down blank I want a message to pop up that says "You must select a payment type!"

Thanks.

detox's picture

They have: 571 posts

Joined: Feb 2001

Jaiem, if the forms are on a server side page, I have a validation-building routine i can send over....

it automatically generates the code for the message and validation given a flag in the form generation code....

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

D -

The form is just a regular ol' HTML page form. I just need some JS for some basic edits, the kind of simple edits FrontPage would do for you (though I'm not using FP!)

Just need to check that certain fields contain values, certain drop-downs have a valid selection etc. and popup a specific (custom) message depending on the error encountered. I don't want a generic "Some info you forgot to enter, please go back and enter it" type of message.

Thanks!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.