Darkelve Posted March 2, 2005 Report Share Posted March 2, 2005 http://www.delijn.be/overheden/contactform_test.html In this contact form I'm making, there are 2 checkboxes. I want to make it so that the person that fills out the form has to check AT LEAST 1 of the 2 checkboxes (e.g. it should return an alertbox with an error message if no boxes are checked.) This is the row containing the code: <tr> <td colspan="2"> <input name="abonnement_op1lijnkrant" type="checkbox" value="Ja" tabindex="20" /> een abonnement op de Op 1 Lijn-krant <br /><br /> <input name="informatie_campagne" type="checkbox" value="Ja" tabindex="20" /> Volgende informatie over de Op 1 Lijn-campagne (aub specifiëren in onderstaand invulveld) </td> </tr> The Javascript I used for the rest of the form can be found in the external file 'form_validation_krant.js' Oh yeah, as you might've gathered, I could also use some Javascript tutorials. If you know any tutorials for beginners, with lots of exercises, let me know! Thanks in advance for the help! Darkelve Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted March 2, 2005 Report Share Posted March 2, 2005 What you want to do is add a clause to your submit button to call javascript code that validates fields.. <input type="submit" value="Save Record" name="btnSubmit" onClick="validate();return returnVal;" tabindex="1"> After that, its up to you to write the javascript code and design a system to define the validation. I suggest that you google on javascript validate and explore various pre-written packages for validating web pages. I could tell you how to do it but its better to research it (learn more, go off on tangents) :) Quote Link to comment Share on other sites More sharing options...
Darkelve Posted March 2, 2005 Author Report Share Posted March 2, 2005 I already have such a construct. But in this case -and I hate to say it- speed is more important than learning. I'm very busy and I don't have time to mess around too much. Well, perhaps this evening during my leisure time... :( All I need to know is if-rule with the or-construct for these checkbox fields. Script is here: http://www.delijn.be/scripts/form_validation_krant.js Quote Link to comment Share on other sites More sharing options...
Darkelve Posted March 3, 2005 Author Report Share Posted March 3, 2005 Nevermind, I found some time and was able to solve it. Although I could still use that Javascript tutorial! :lol: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.