What is the meaning of onsubmit="return false"? (JavaScript, jQuery) -


i know onsubmit event occurs when form submitted.

generally is, calling method on onsubmit event <form action="" onsubmit="myfunction()">

today saw this, "<form action="" onsubmit="return false">". how works? not understand meaning of onsubmit="return false".

ps : found when learning ajax. tutorial explains how submit data database without refresh page.

this done manually handle form submission.

for example - for validation purpose see below code , see how can beneficial:

<script language="javascript"> myfunctionname() {     if (document.myform.mytext.value == '')         return false;         //when return false - form not submit , not redirect     else         return true;      //when return true- form  submit ,  redirect // (actually part of submit) id have mentioned in action } </script>  <form name="myform" onsubmit="return myfunctionname()"> <input type="text" name="mytext"> <input type="submit" value="click me"> </form> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -