Working perfectly.This exmple will help alot.
Working perfectly.This<script> exmple will help alot. function check() { var val = frm1.uname.value; //alert(val); if (val.indexOf("@") > 0) { alert ("email"); document.getElementById('isEmail1').value = true; //alert( document.getElementById('isEmail1').value); } else { alert("usernam"); document.getElementById('isEmail1').value = false; //alert( document.getElementById('isEmail1').value); } } </script> </head> <body> <h1>My form </h1> <form action="v1.0/user/login" method="post" id = "frm1"> <p> UserName : <input type="text" id = "uname" name="username" /> </p> <p> Password : <input type="text" name="password" /> </p> <p> <input type="hidden" class="email" id = "isEmail1" name = "isEmail"/> </p> <input type="submit" id = "submit" value="Add User" onclick="return check();"/> </form> </body>