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 6357397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:09:28+00:00 2026-05-24T23:09:28+00:00

I am fairly new to jQuery and JavaScript in general. I have a form,

  • 0

I am fairly new to jQuery and JavaScript in general.

I have a form, and what I want to do it have the form run a function to make sure everything is there, and all the variables are correct then submit.

I have used onclick value to the submit button and have it run a function that uses preventDefault(). I am not sure if im using it correctly but it doesn’t seem to be working.

This is what I have and when you click submit, it just submits even if the if statement is false.

function checkSubmitStatus() {
    $("#myform").submit(function(event){
        if( whatever==true) {
            event.preventDefault(); 
        }
    });
}

<input type="submit" name="submit" value="Submit"  onClick="checkSubmitStatus()">

Thanks!

  • 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-05-24T23:09:29+00:00Added an answer on May 24, 2026 at 11:09 pm

    By putting $("#myform").submit(...) inside the checkSubmitStatus() function, you’re attaching the submit handler after the button is clicked and the form is already submitted. Try this:

    <script type="text/javascript">
    $(document).ready(function() {
      $("#myform").submit(function(event){
        if(whatever) { 
           event.preventDefault();  
        }  
      });
    });
    </script>
    
    <form id="myform">
      <input type="submit" name="submit" value="Submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to JQuery and Javascript in general. I don't think I'm trying
(I'm fairly new to jQuery.) I have a traditional HTML form with 3 drop-down
I'm pretty new to javascript and jquery, and have run into a problem that
Fairly new to jQuery and JavaScript in general. I mocked up an example of
I am fairly new to Jquery and javascript and have jumped in head first
I'm fairly new to JQuery and I'm trying to add multiple form fields for
I'm fairly new to JavaScript/jQuery/AJAX, so I suspect the issue is some typo I'm
I'm fairly new to Javascript/JQuery. I'm trying to write an app that takes text
Possible Duplicate: When should I use a javascript framework library? All, I'm fairly new
I'm fairly new to jQuery and JavaScript, and I've been trying to implement a

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.