When the form element is submitted, JS determines that the input value is empty, does not refresh the page return, does not jump to the null and passes the value to the new page

Source: Internet
Author: User

<body> <div id="Div1"style="Display:block;"> <div id="logo"></div> <div id="word1"></div> <div id="Word2"></div> <form name="Form1"Method="Get"action="zhengshu.php"onsubmit="return Submitcheck ();">-----Key return + function name implemented as NULL returns the original interface------------<div id="username"> <div id="content"> <input type="text"Name="User"Id="User"  class="BGC"autofocus="Autofocus"Placeholder="Your name"/> <div>"Images/word3.svg"/></div> </div> </div> <input type="Submit"Id="Sub"Value="Submit"></div> </form> </div> </body> <script type="Text/javascript">function Submitcheck () {vartxt = document.getElementById ("User"); if(txt.value=="") {alert ("Please enter your name");            Txt.focus (); return false; }            return true; }      </script>
<? php       $username=$_get['user'];------- receive the value     passed ?> <div id="link"><?php echo $username?></div> the value-----output.

When the form element is submitted, JS determines that the input value is empty, does not refresh the page return, does not jump to the null and passes the value to the new page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.