Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8141057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:22:16+00:00 2026-06-06T12:22:16+00:00

I usually work with PHP so sadly don’t have some basic JS principles down.

  • 0

I usually work with PHP so sadly don’t have some basic JS principles down. This is all I want to accomplish–I’ve seen many posts on this topic but they are usually beyond what I need.

Here is my form:

 <input type="checkbox" name="checkbox" value="check"  />
 <input type="submit" name="email_submit" value="submit" onclick="----??----"  />

The checkbox is a simple “I agree”. I want the submit button to be pressed and it will only submit if that check box is selected.

Here’s the thing: I want the simple, cheating way — no methods — just some inline code in that form (assuming its not overly long?). This is not a public page, I just need something quick and simple with that type of validation. If its unchecked, it will throw an alert(); if its checked it will submit via post through php and go on as normal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:22:18+00:00Added an answer on June 6, 2026 at 12:22 pm

    You could use:

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

    (demo page).

    <input type="checkbox" name="checkbox" value="check"  />
    <input type="submit" name="email_submit" value="submit" onclick="if(!this.form.checkbox.checked){alert('You must agree to the terms first.');return false}"  />
    
    • Returning false from an inline event handler will prevent the default action from taking place (in this case, submitting the form).
    • ! is the Boolean NOT operator.
    • this is the submit button because it is the element the event handler is attached to.
    • .form is the form the submit button is in.
    • .checkbox is the control named “checkbox” in that form.
    • .checked is true if the checkbox is checked and false if the checkbox is unchecked.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I usually work with PHP but need to setup this JSP with a server
I usually work with .NET but I have a php page that calls an
I found that this works sporadically, but usually doesn't work at all. $(window).unload(function() {
I work with Mac OS X Leopard. I usually have 5 or 10 text
Possible Duplicate: Why use a framework with PHP? Hi, usually all the projects I
I usually use Netbeans for PHP development, but have recently had to move to
I usually work with PHP MySQL and resultantly, my knowledge with MsSQL is somewhat
I do PHP coding a lot in my company and personal work. Usually my
I have to work with another team that is developing in php, when I'm
I am losing hair over this. All I want is to append the Session

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.