Creating Reusable Validation Code : Validation : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » Validation »

 

Creating Reusable Validation Code



<html>
<head>
<title>Integer Validation</title>
<script language="JavaScript">
<!--
function isInt(textObj) {
   var newValue = textObj.value;
   var newLength = newValue.length;
   for(var i = 0; i != newLength; i++) {
      aChar = newValue.substring(i,i+1);
      if(aChar < "0" || aChar > "9") {
         return false;
      }
   }
   return true;
}
// -->
</script>

</head>
   
<body>
<h1>Integer Validation</h1>
<form name="form1">
<input type="text" size=16 maxlength=16 name="data">
<input type="button" name="CheckButton" value="Validate" onClick="document.form1.result.value = '' + isInt(document.form1.data)">
<br>
Result <input type="text" size=16 maxlength=16 name="result">
</form>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» Validation