Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 注册页面按钮不是';不要将我重定向到另一页 注册 请填写此表格以创建帐户 电邮: 密码: 重复密码: 报名! var email=document.getElementById(“email”).value; 功能电子邮件(){ if(document.getElementById(“密码”).value==document.getElementById(“重复密码”).value&&email.include(“@”)==true){ location.href=“question2.html”; } }_Javascript_Html - Fatal编程技术网

Javascript 注册页面按钮不是';不要将我重定向到另一页 注册 请填写此表格以创建帐户 电邮: 密码: 重复密码: 报名! var email=document.getElementById(“email”).value; 功能电子邮件(){ if(document.getElementById(“密码”).value==document.getElementById(“重复密码”).value&&email.include(“@”)==true){ location.href=“question2.html”; } }

Javascript 注册页面按钮不是';不要将我重定向到另一页 注册 请填写此表格以创建帐户 电邮: 密码: 重复密码: 报名! var email=document.getElementById(“email”).value; 功能电子邮件(){ if(document.getElementById(“密码”).value==document.getElementById(“重复密码”).value&&email.include(“@”)==true){ location.href=“question2.html”; } },javascript,html,Javascript,Html,我想在单击注册按钮时重定向到另一个html页面,电子邮件输入字段包含“@”,密码输入字段值与repeatpassword相同,但我不知道我的代码有什么问题,请使用脚本函数中的window.location.href进行重定向。 如需更多参考,请留意 Button onclick=“email()”括号是必需的,因为您在单击按钮时调用函数 函数无法访问在函数外部声明的变量。因此,在函数范围内声明email变量 它不是email.include()函数,而是includes()。“s”不见了。参

我想在单击注册按钮时重定向到另一个html页面,电子邮件输入字段包含“@”,密码输入字段值与repeatpassword相同,但我不知道我的代码有什么问题,请使用脚本函数中的
window.location.href
进行重定向。 如需更多参考,请留意

  • Button onclick=“email()”括号是必需的,因为您在单击按钮时调用函数

  • 函数无法访问在函数外部声明的变量。因此,在函数范围内声明email变量

  • 它不是email.include()函数,而是includes()。“s”不见了。参考号-

  • 功能电子邮件(){
    var email=document.getElementById(“email”).value;
    if(document.getElementById(“密码”).value==document.getElementById(“重复密码”).value&&email.includes(“@”)==true){
    控制台日志(“工作”);
    }
    否则{
    控制台日志(“不工作”);
    }
    }
    注册
    请填写此表格以创建帐户

    电邮:

    密码:

    重复密码:


    报名
    应该是
    email.includes(“@”)==true
    (注意复数)
    
    <body>
    
    
    <h1 style="color:red;">SIGN UP</h1>
    <p style="color:blue;">Please fill in this form to create an account.</p>
    
    
      <label for="Email">Email:</label> 
      <input type="text" id="Email" name="Email"><br><br>
      <label for="password">password:</label>
      <input type="text" id="password" name="password"><br><br>
    <label for="repeatpassword">repeatpassword:</label>
      <input type="text" id="repeatpassword" name="repeatpassword"><br><br>
    <button onclick="email" >SIGNUP!</button>
    
      
    
        <script>
    var email = document.getElementById("Email").value;
    
    
    function email(){
    if(document.getElementById("password").value===document.getElementById("repeatpassword").value && email.include("@")== true){
    location.href = "question2.html";
    }
    
    }
    
    
    
    
    </script>
    </body>
    </html>