String Validation : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

String Validation




<html>
<head>
<title>String Validation</title>
<script language="JavaScript">
<!--
function isString(textObj) {
   var newValue = textObj.value;
   var newLength = newValue.length;
   var extraChars=". -,";

   var search;
   for(var i = 0; i != newLength; i++) {
      aChar = newValue.substring(i,i+1);
      aChar = aChar.toUpperCase();
      search = extraChars.indexOf(aChar);
      if(search == -&& (aChar < "A" || aChar > "Z") ) {
         return false;
      }
   }
   return true;
}
//-->
</script>
</head>
   
<body>
<h1>String Validation</h1>
<form name="form1">
<input type="text" size=16 name="data">
<input type="button" name="CheckButton" value="Validate" onClick="document.form1.result.value = '' +
    isString(document.form1.data)">
<br> Result <input type="text" size=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 Language Basics
» String