PDA

View Full Version : how to validate currency field


petertran123
07-16-2002, 04:06 PM
Hello all,

I created a currency field format as "0.00" then wanted to confirm user that whether they are entering dollars amount or not. If they are entering the amount greater than zero, then it send when hits submit. But if they are not entering any dollars amount in the currency field or entering zero dollars amount, then they will promt a message said " you did not enter any fees. Is this correct? If yes then to submit, or no to return to the previous screen" something like this. Can someone help me with this.? I truly appreciate it.

Peter.

tamienne
07-16-2002, 04:24 PM
function checkAmount() {
var theAmount = Number(document.formName.currencyField.value);
if (theAmount <= 0) {
theAnswer = confirm("The Amount is $0. Is this correct?");
return theAnswer;
}
}

<FORM NAME="formName" onSubmit="return checkAmount();">

petertran123
07-16-2002, 04:43 PM
Thanks for your big help Tamienne. It works great with my code...