Lets have a running example to depict this concept.
alert('Kindly enter number in price.');
x.txtiprice.focus(); return false;
form id="frmCheckout" name="frmCheckout" onsubmit="return validateform(this);"
input id="txtiprice" maxlength="50" size="30" name="txtiprice"
inputname="btn" id="btn" value="Submit" type="submit"
We have defined a funciton "validateform()" at the top and then have called it whenever the form "frmcheckout" will be submitted. In the validateform() function, the condion checks that if the value submitted in txtiprice text box is number or not and then return true or false.