javascript - Add CSS when there's an error -


i have simple login page i'm having trouble with. when type in incorrect info runs alert, want add css backgrounds of fields makes them red. how go editing following code this?

here's fiddle.

thanks.

<html> <head>     <link rel="stylesheet" type="text/css" href="styles.css" />     <title>jeremy blaz&eacute;</title> </head> <body>     <div id="box">         <img src="logo.png" />         <form name="login">             <input type="text" name="userid" placeholder="username" />             <input type="password" name="pswrd" placeholder="password" />             <input type="submit" class="button" onclick="check(this.form)" placeholder="password" value="sign in" />         </form>     </div>     <script language="javascript">     function check(form) {         if(form.userid.value == "username" && form.pswrd.value == "password") {             window.open('dashboard/index.html')         }         else {             alert("error password or username")         }     }     </script> </body> </html> 

// js else {     alert("error password or username");     document.login.class = "error"; }  // css form.error input[type="text"], form.error input[type="text"] {     background-color: red; } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -