Journal » Post
|
|
Recently I was working on a site which required multiple groups of checkboxes, since it was a site that gathered data through a survey... don't ask what site it is. At first I though of PHP to handle the validation but the code will take way too long and if we need to go back to the page it would be hard to cache the data already passed. Hence my javascript solution; the advantage of this is that we validate the form first before anything is passed to the server, the obvious disadvantage is it wont work if javascript is disabled. The idea is to cache all the group names into an array and check each group if a value was selected; then do the necessary prompts and what not. so first up is the function to check our array:
Now the function to check the form, I fire this function with the onsubmit event, and passing the form name to it like so:
And the function...
|



