需要帮忙!外部JavaScript只是不起作用... [英] NEED HELP! External javascript just won't work...

查看:71
本文介绍了需要帮忙!外部JavaScript只是不起作用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编码的初学者,我刚刚尝试制作一个简单的登录页面,其中包含一个链接到它的外部JavaScript ...但是当我启动HTML并单击show按钮时,javascript将无法正常运行。< br $>


HTML代码:



I am a beginner at coding and I just recently tried out making a simple login page with an external javascript linked to it ... But when I start up the HTML and click the show button the javascript won't function.

The HTML CODE:

<HTML>

  <HEAD>
    <TITLE> Log In | Page </TITLE>
      <SCRIPT Type='text/javascript' src="main.js">
      </SCRIPT>
  </HEAD>

  <BODY>
    <CENTER>
        <FONT Face="Lucida Bright" size="28">  WELCOME 
        </FONT>
            <BR> <BR>
      <FORM Name="Mainform">
        <FONT Face="Lucida Bright" size="5">
          Username    
          <INPUT Type="text" Name="Usrnm" size="15">
            <BR> <BR>
          Password    
          <INPUT Type="password" Name="Usrps" size="15">
            <BR> <BR> <BR>
          <INPUT Type="button" Name="Login" Value="Show" onclick="event()">
        </FONT>
      </FORM>
    </CENTER>
  </BODY>

</HTML>





JAVASCRIPT代码:





The JAVASCRIPT CODE:

function event() {
  var usrread= document.Mainform.Usrnm.value;
  var pswread= document.Mainform.Usrps.value;

    if (usrread.length<=3)
      {
        alert("Your username must contain at least 4 Characters!");
          alert("Wrong Data! Please check again.");
        return;
      }

    if (pswread.lenth<=5)
    {
      alert("Your password must contain at least 6 Characters!");
        alert("Wrong Data! Please check again.");
      return;
    }

    if (isNaN(pswread.charAt(0))==True || isNaN(pswread.charAt(1))==True)
    {
      alert("The first two characters in the Password must be Numbers!");
        alert("Wrong Data! Please check again.");
      return;
    }

    if (usrread.length>=3 && pswread.lenth>=5 && isNaN(pswread.charAt(0))==False
        && isNaN(pswread.charAt(1))==False)
    {
      alert("Correct Data");
      return;
    }
}







请帮忙!提前谢谢!



我尝试了什么:



我尝试了在线验证器,它说没有错误。所以我猜必须有一些逻辑错误。如果你能指出这一点,我会很高兴的。 :)




Please Help! Thank you in advance!

What I have tried:

I tried the online validators, and it says there are no errors. So I guess there must be some logic error. I would be so happy if you would point that out. :)

推荐答案

更改函数名称: JavaScript保留字 [ ^ ]
Change the function name: JavaScript Reserved Words[^]

这篇关于需要帮忙!外部JavaScript只是不起作用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆