Jump to content

Noob request i know ...


iPixel

Recommended Posts

I've got 2 radio buttons...

 


Agreement txt here Agreement txt here Agreement txt here Agreement txt here 
Agreement txt here Agreement txt here Agreement txt here Agreement txt here 
Agreement txt here Agreement txt here Agreement txt here Agreement txt here 

<form action="#" method="POST">
<input type="radio" value="YES" name="agreement">YES <br />
<input type="radio" value="NO" name="agreement">NO <br />
<input type="submit" value="Submit" name="submit" />
</form>

 

No what i want is that unless the "YES" radio button is checked... pop up an alert saying u must agree to continue.

 

the weird thing, ok..

 

I used


function chkAgreement()
  {
     alert('You must agree to the terms before you continue');
  }

but even after you hit OK it just goes to where the action points...

 

confirm('msg') i dont really want to use because i dont want the cancel button there.. just the OK.

 

So how do i prevent the form being submitted unless the YES radio button is selected.

 

Thanks

Link to comment
Share on other sites

I believe what you need is a conditional in your chkAgreement() function that checks to see if your checkbox is checked. Just off the top of my head, haven't tested it or anything. Then, instead of using a submit button simply tie your button to your JS function and use the JS to submit the form if the appropriate field is checked.

 

function chkAgreement() {
    if (document.myform.agreement.value=='YES') {
        document.myform.submit();    
    } else {
        alert('You must agree to the terms before you continue');
        return false;
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.