How to check for empty values on two fields then prompt user of error using javascript
- by Matthew
Hello guys,
I hope I can explain this right I have two input fields that require a price to be entered into them in order for donation to go through and submit.
The problem that I am having is that I would like the validation process check to see if one of the two fields has a value if so then proceed to submit. If both fields are empty then alert.
This is what I have in place now:
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(input1,"Need a donation amount to continue")==false)
{input1.focus();return false;}
else if (validate_required(input2,"Need a donation amount to continue")==false)
{input2.focus();return false;}
}
}
I would like to ultimately like to get this over to Jquery as well
Thanks guys any help would do
Matt