0

Using Jquery I would like to suppress additional logic if my form didn't pass validation,this code work OK,

   $( "#myForm" ).submit(function( event ) {
        alert( "Form is invalid!" );
        event.preventDefault();
    });

I am wondering What is the differences between the three methods below and which one to use?

Event.stopPropagation()
Event.cancelBubble()
Event.preventDefault()
JavaSheriff
  • 7,074
  • 20
  • 89
  • 159
  • 1
    `Event.cancelBubble` isn't a function, it's a property that you assign to. It's considered obsolete, and has been replaced with `Event.stopPropagation()`. – Barmar May 19 '17 at 20:34
  • 1
    return false; should stop any thing else from executing -- if($("#uername").val() == ""){/*the user name was empty*/return false;} – linc May 20 '17 at 01:27

0 Answers0