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
Release: 2016-06-24 11:57:30
Original
1384 people have browsed it






方法调用




    

登录系统 


    
    

用户名:
     
    


      

密码;                        
      
      

       
  

         
            
    
        
        
                   /*点击按钮“很好”时,没有反应*/
  








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>
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template