BTW: Form validation is best done on the client side for efficiency.
(better suited in a javaScipt forum, however..)
TIP: Put the call to the function in your <form> tag instead of your submit or button tag, this way the form can be submitted by pressing enter OR Clicking:
<form name="someName" action="someAction" method="post" onSubmit="return validate();">
NOTE:Place the following inside script tags after the <head> and before the </head>:
function validate()
{
//To ensure a value is a integer
if(isNaN(parseInt(document.formName.orderNumber.va lue)))
{
alert("please enter a valid positive integer");
//focus the incorrect field
document.formName.orderNumber.focus();
//select the incorrect text
document.formName.orderNumber.select();
return(false);
}
//is order number bigger than stock
if(document.formName.orderNumber.value > document.formName.stock.value )
{
alert("The order number is bigger than the stock value");
document.formName.orderNumber.focus();
document.formName.orderNumber.select();
return(false);
}
return(true);
}
JS is case and space sensitive remember
Wind is your friend
Matt