jimfog Posted May 16, 2013 Share Posted May 16, 2013 I am not so experienced in js and as such I have this question;Here is some code: $(function() { $('.error').hide(); $(".button").click(function() { $('.error').hide(); var name = $("input#name").val(); if (name == "") { $("label#name_error").show(); $("input#name").focus(); return false; } // validate and process form here }); }); Why the if statement above has a "return false" statement in it.Is there a difference in the false statement between PHP and JS. Link to comment Share on other sites More sharing options...
Ingolme Posted May 16, 2013 Share Posted May 16, 2013 Return false returns the boolean "false" when the function is executed. Since this is a click event, that means that the default actions that clicking causes shouldn't occur. It's the same as in PHP. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now