I have 2 fields I need to validate in a form.
One is a drop-down box with a few options. The second is a text box where the user can enter their own value.
The way it should work is that either the user can choose one option from the drop down box or enter his own value in the text box. But one of the two have to be filled.
I am trying the following code, but it is stuck on the first validation. Keeps asking to choose from the drop-down even if something is already entered in the text box below. It should be an either / or thing, or an if.. then.. else.. thing, but I am not sure of the syntax. Please help.
One is a drop-down box with a few options. The second is a text box where the user can enter their own value.
The way it should work is that either the user can choose one option from the drop down box or enter his own value in the text box. But one of the two have to be filled.
I am trying the following code, but it is stuck on the first validation. Keeps asking to choose from the drop-down even if something is already entered in the text box below. It should be an either / or thing, or an if.. then.. else.. thing, but I am not sure of the syntax. Please help.
Code:
if (x.budget_range.value == '1')
{
alert("Please choose a budget range");
x.budget_range.focus();
return false;
}
if
((x.budget_range.value == '1') && (isBlank(x.budgetamt.value)))
{
alert("Please enter a budget");
x.budgetamt.focus();
return false;
}
}
Comment