Tuesday, March 30, 2010

some javascript form checking

I need to have a form validation that depends on which item is selected.

i have 5 fields

PRCS - can have values of 1 2 3 or 4

QTY1 - needs to have value greater than 50 entered.

QTY2

QTY3

QTY4

so what i need is if PRCS=1 then QTY1 value needs to be greater than 50.

%26lt;script type=''text/javascript'' language=''JavaScript''%26gt;
%26lt;!--
function QTYVAL(theForm) {
if (theForm.PRCS.value == '1' and theForm.QTY1.value %26lt; 50)
{
?alert ('Minimum quantity is 50.');
?return false;
} else {?
?return true;
}
}
//--%26gt;
%26lt;/script%26gt;

and in my form i have onsubmit=''return QTYVAL(this);

WHAT AM I DOING WRONG?!

some javascript form checking

its %26amp;%26amp; in javascript, not and.

if (theForm.PRCS.value == '1' and theForm.QTY1.value %26lt; 50)

should be:

if (theForm.PRCS.value == '1' %26amp;%26amp; theForm.QTY1.value %26lt; 50)

No comments:

Post a Comment