<%@ LANGUAGE=JAVASCRIPT %>

<html>

<head>

<title>Form Validation Using JavaScript</title>

<script LANGUAGE="JavaScript">

<!-- Hides Code

function validateIt() //function is called when the button is clicked

{

var dblNum;

var txtText;

var txtMessage;

dblNum = 0.1;

if(!isNaN(document.form1.txtNum.value)) /* document.[form name].[field name].value Checks to see if it is a number (isNaN: Not a Number) */

{

dblNum = document.form1.txtNum.value; /* alerts display message boxes */

}

else

{

alert("Field must contain a number");

document.form1.txtNum.focus();

return;

}

txtText = document.form1.txtText.value;

if(!isNaN(document.form1.txtText.value))

{

alert("Requires text, and not a number");

document.form1.txtText.focus();

return;

}

if(txtText.length < 8) /* checks to see if the lenght of the text field is greater than 8 */

{

alert("Text must be at least 8 letters long");

document.form1.txtText.focus();

return;

}

if(dblNum < 250.55) /* makes sure that the number entered meets the criteria */

{

alert("Number must be greater than 250.55")

document.form1.txtNum.focus();

return;

}

alert("Everything Checks Out Fine")

return;

}

//-->

</script>

</head>

<body background="../images/aspfreebkgrnd.gif">

<p>How to validate a form entry using javascript:</p>

<form method="POST" name="form1" action="javaform.asp" webbot-action="--WEBBOT-SELF--">

<div align="center">

<center>

<table border="0" cellpadding="0" cellspacing="0" width="44%">

<tr>

<td width="41%">Text of 8 letters: </td>

<td width="59%"><input type="text" name="txtText" size="20"></td>

</tr>

<tr>

<td width="41%">Number &gt; 250.55</td>

<td width="59%"><input type="text" name="txtNum" size="20"></td>

</tr>

<tr>

<td width="41%" colspan="2">

<p align="center"><input type="button" value="Button" name="B1" onClick="validateIt();"></td></tr>

</table>

</center>

</div>

</form>

</body>

</html>