Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
Several ways of preventing a form to submit the normal way?

I have a little php experience and would like to learn ajax jQuery. I've been watching several tutorials on submitting a form without refreshing the page. I notice people use different ways to prevent a form from submitting the normal way (with a page refresh):

  • with the event.preventDefault() function
  • using return false
  • In a script I'm trying to understand the JS script starts with:

    $("#submitBrandForm").unbind('submit').bind('submit', function() {

Does this also have the same functionality? This same script ends with 'return false', which confuses me (and makes me think the unbind - bind code has another purpose).

Thanks

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No, the third one doesn't do the same thing. unbind only removes any previously attached event handlers (via bind), it does not prevent the form from being submitted.

In your example unbind and bind are just used to replace the existing event handler(s). If you don't unbind first, bind will add a handler to the ones that are already attached. You'll also often see unbind('submit', ...) inside the handler for a submit event that programmatically submits the form, to prevent the function from calling itself endlessly, like in this answer.

By the way, bind and unbind have been deprecated, you should be using on and off.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!