zoukankan      html  css  js  c++  java
  • 使用代码提交表单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" language="javascript">
     //验证邮箱
     function checkEmail(){
      var email = document.myform.txtEmail.value;
      if(email.indexOf("@")<0){
       alert("邮箱必须有@符号");
       return false; 
      }else if(email.lastIndexOf(".")<0){
       alert("邮箱必须有.符号");
       return false;
      }else if(email.indexOf("@")>email.lastIndexOf(".")){
       alert("@符号一定要在最后一个.前面"); 
       return false;
      }
      return true;
     }
     
     function clearEmail(){
      document.myform.txtEmail.value = ""; 
     }
     //用代码提交表单
     function formSubmit(){
      if(checkEmail()){
       document.myform.submit();//提交表单
      } 
     }
    </script>

    </head>

    <body>

    <form action="http://www.baidu.com" method="get" name="myform">  

    您的电子邮箱:<input type="text" name="txtEmail" /><br />      

      <input value="清空" onclick="clearEmail();" type="button" />   

         <input type="button" onclick="formSubmit();" value="注册"/>

    </form>

    </body>

    </html>

  • 相关阅读:
    The AndroidManifest.xml File
    handlebars简单用法
    高性能跨语言模板引擎Crox
    C++17 新特性
    C++ 14新特性
    [lua]笔记
    [lua]笔记
    delphi关键字
    delphi 基础
    TCP/UDP
  • 原文地址:https://www.cnblogs.com/danmao/p/3815838.html
Copyright © 2011-2022 走看看