»
EnglishFrenchVietnamese

Print - Validation (Information) - JavaScriptBank.com

Full version: jsB@nk » Form » Validation » Validation (Information)
URL: https://www.javascriptbank.com/validation-information.html

Validation (Information) © JavaScriptBank.comTest the powers of Javascript. Watch as JavaScript tells you if information about you is valid or not.

Full version: jsB@nk » Form » Validation » Validation (Information)
URL: https://www.javascriptbank.com/validation-information.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!-- Beginfunction validate(){var digits="0123456789"var tempif (document.testform.Name.value=="") {alert("No Name !")return false}if (document.testform.age.value=="") {alert("Invalid Age !")return false}for (var i=0;i<document.testform.age.value.length;i++){temp=document.testform.age.value.substring(i,i+1)if (digits.indexOf(temp)==-1){alert("Invalid Age !")return false      }   }return true}// End --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name="testform" onSubmit="return validate()">Name:<input type="text" size=30 name="Name">Age:<input type="text" size=3 name="age"><input type="submit" value="Submit"></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->