Jump to content

Javascript help


Recommended Posts

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

Link to comment
Share on other sites

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) :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...