Home >Web Front-end >HTML Tutorial >html calls JavaScript function, but no display effect? _html/css_WEB-ITnose

html calls JavaScript function, but no display effect? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:301375browse

b585974ae3b7dba3039af53a9593f9c4
383eb734b02b508089ba2d78eb4c6f68
93f0f5c25f18dab9d176bd4f6de5d30e
5e18004130b03fd4aaa01fe61a84ebb1
    

function method1(){
  var i=1;
  var j=1;
   
   for( i=1;ie8255ba28b0f837b19204b2bf6b11de0');
      }
}
function fun()
{
   alert('你好!!');
}


function jianche(){                  /*  此函数的调用出现问题  */
   var str=form1.user.value;
   if(str==""){
     alert("请输入真实姓名!");
 form1.user.foucs();

   else{
     var objExp=/[\u4E00-\u9FA5]{2,}/;
   if(objExp.test(str)==ture){
   alert("输入了正确的名字!");
    
       }
   else {
      alert("输入的名字不正确!");
       }
}
   
}

2cacc6d41bbb37262a98f745aa00fbf0
ebeda52af7641f7e715679a8472f8c69
b2386ffb911b14667cb8f0f91ea547a7方法调用6e916e0f7d1e588d4f442bf645aedb2f
46d5fe1c7617e3914f214aaf043f4ccf
97704f9e853877b944a47805e31cdd0f
531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
77a9e60f230f7b87a2872e9a60a609d8
    e802318aa200e2cd9180b5edaf529468登录系统 94b3e26ee717c64999d7867364b1b4a3
    
    9518bebdf3d8eaf41f598d8c83ac03da用户名:
     fdeec8df6c32e4f731d904b348dd58a1
    94b3e26ee717c64999d7867364b1b4a3
      9518bebdf3d8eaf41f598d8c83ac03da密码;                        
      c8d28753c687f445d7590f1aa1cb4a38
      94b3e26ee717c64999d7867364b1b4a3       
  be36754878d1c04af1a09c763c335e2c
        91af64140e1c9798012675b4a9adc345 
        a5ee39c53151f4a56149c4643709e471    
b36b5916e23250a60cacc86ec434287f    
        
        fcc35632ee4d458be3fa6e3728b6ad78
        1d5dda84c17df8e32b1c2c0f11827271           /*点击按钮“很好”时,没有反应*/
  16b28748ea4df4d9c2150843fecfba68
f5a47148e367a6035fd7a2faa965022e

36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e



Problem: Clicking button "OK", no reaction? Ask God for answers! Thanks!


Reply to discussion (solution)

Yes focus()
Not foucs()

Except foucs In addition to the problem, the following 2 lines also have issues with compatibility or code.
var form1 = document.form1;
var str = form1.user.value;
if(objExp.test(str) == true){

<!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>    <script language="javascript">        function method1(){            var i = 1;            var j = 1;            for(i = 1; i <= 9; i++){                for(j = 1; j <= i; j++){                    document.write(i + "*" + j + '=' + i * j + "  ");                }                document.write('<br>');            }        }        function fun(){            alert('你好!!');        }        function jianche(){                  /*  此函数的调用出现问题  */            var form1 = document.form1;            var str = form1.user.value;            if(str == ""){                alert("请输入真实姓名!");                form1.user.focus();            } else {                var objExp = /[\u4E00-\u9FA5]{2,}/;                if(objExp.test(str) == true){                    alert("输入了正确的名字!");                } else {                    alert("输入的名字不正确!");                }            }        }    </script>    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>    <title>方法调用</title>    <style type="text/css">        <!--        .STYLE1{ font-size:xx-large }        -->    </style></head><body><form id="form1" name="form1" method="post" action="">    <p align="center" class="STYLE1">登录系统</p>    <p align="center">用户名: <input type="text" name="user"/></p>    <p align="center">密码; <input type="password" name="password"/>    </p>    <div align="center">        <input type="submit" name="Submit" value="提交"/> <input type="reset" name="Submit2" value="重置"/>        <input type="button" name="Submit3" onclick="method1()" value="检测"/>        <input type="button" name="Submit4" onclick="fun()" value="好"/>        <input type="button" name="Submit5" onclick="jianche()" value="很好"/> /*点击按钮“很好”时,没有反应*/    </div></form></body></html>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn