Jump to content

Validate Multiple Forms


justinbriggs1

Recommended Posts

Hello, I added another form to my page and would like to validate it with the same javascript page I created for form validation, but I'm not sure how to go about doing it. Here's part of the js code:function checkScript() { var val = true; if (document.newbonus.bonus_name.value == "") { alert('You must enter a bonus name.'); val = false; }......How do I pass in any particular form as an argument without the form name? Been a while since I've programmed.... Thanks!

Link to comment
Share on other sites

I've never yet written a form that was so generic I could pass a form reference to one master validator and it could guess what I want. I always write custom validators. This involves keeping assigning an ID to each form element, getting a reference to each element with document.getElementById(), and then testing the element's value against whatever is appropriate to the context.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...