1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 <style>7 Div{8 Margin-bottom:20px;9 }Ten One fieldset{ A width:300px; - } - </style> the </Head> - <Body> - <fieldset> - <legend>User Login</legend> + <formAction=""Method=""> - <Div><label for= "Name">User name</label> + <inputtype= "text"ID= "Name"><BR> A </Div> at <Div><label for= "Pass">Dense Code</label> - <inputtype= "text"ID= "Pass"> - </Div> - <inputtype= "Submit"value= "Login"ID= "Login" - style= "Display:block; - margin-left:100px "> in </form> - </fieldset> to <Scripttype= "Text/javascript"> + function$$ (ID) { - returndocument.getElementById (ID); the } * functionCheck () { $ var$n= $$("name");Panax Notoginseng var$p= $$("Pass"); - if($n. Value== "") { the Alert ("Please enter the user name!"); + $n. focus (); A return false; the } + if($p. Value== "") { - Alert ("Please enter your password!"); $ $p. focus (); $ return false; - } - } the $$("Login"). onclick= function () { - returncheck ();Wuyi } the </Script> - </Body> Wu </HTML>
text Box gets focus