The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> HTML Form Validation Help, HTML Code Help
SamCaunt
post Nov 29 2016, 04:29 AM
Post #1





Group: Members
Posts: 1
Joined: 29-November 16
Member No.: 24,945



Hi All,

At the minute my code validates whether the checkbox is checked, if its not checked it returns a message.

When the checkbox is checked and my user hits the "Accept" button I want to then run a function in java how do I do this???.

Many Thanks
Sam

QUOTE

<center><form>
<input type="checkbox" name="checkbox" value="check" /> I accept the terms and conditions

<p align=center><input type="button" name="Submit" value="Accept" class="button" onclick="if(!this.form.checkbox.checked){alert('You must agree to the terms first.');return false}" /></p>

<p align=center><input type="button" name="Reject" value="Reject" class="button" onclick="reject();"></p>
</form></center>



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 29 2016, 08:05 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



What function? Surely not the same as when the checkbox isn't checked?

You can can add an else statement the triggers when the if condition is not met.
CODE

onclick="if(!this.form.checkbox.checked){alert('You must agree to the terms first.');return false}else{alert('Whatever');}"

User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 06:22 PM