john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

javascript validate html form

<html>
<body>

<form style ='margin: 0px; padding: 0px;' id='logout' action='test.html' method='post' onsubmit='validateFormOnSubmit()' >

<label>AD/LDAP Server Address: </label>&#xA0;&#xA0; <input type='text' id='ldapServerHost' name='ldapServerHost' size='40' value='10.10.10.235' /> <br /><br />
<div><input type='submit' name='logout' value='logout' /></div>

</form>
<script type='text/javascript'>
function validateFormOnSubmit()  {

  var x=document.getElementById( 'ldapServerHost' ).value;

  if (x==null || x=='' )
  {   alert('password cannot be empty');
      return false;
  }
}
</script>


</body>
</html>

  • « AppProperties TEST AuthgatewayServiceDAOTest
  • PropertiesDuplicateCheckerTest »

Published

Jun 26, 2012

Category

javascript

~53 words

Tags

  • form 20
  • html 23
  • javascript 43
  • validate 2