Saturday, 23 April 2016

Simple Validation in JavaScript:

Javascript can have simple validations and such an example is given below. Download and use the code.
 

<html>
<head>

</head>
<body>

Input numbers between 0 and 5

</body> </html>
functions.js
 

function validate()
{
var x, text;
x = document.getElementById("numb").value;
if(isNaN(x) || x < 1 || x > 5)
{
text = "Input not valid";
}else
{
text = "Input OK";
}
document.getElementById("show").innerHTML = text;
}



No comments:

Post a Comment