I have recently set up a product with variants that allows us to have a customer enter their account number before sending us a payment. We can then post the payment to the proper account, since we have the account number. now I want to provide some basic validation to verify that the customer has not left the Account number variant text field blank.
After browsing google and this forum, I found a link to
http://www.elated.com/articles/form-validation-with-javascript/ , which seems promising. However, I cannot seem to make it work, and I think it is due to the fact that the "Add to Cart" button is running a javascript, not performing a post operation. Either way, I added a name to the form in the e-junkie button code, and then adapted the script in the example linked above to validate the os0 variable to verify that it is not blank.
Any ideas on what I am missing here?
I changed [code]<form action="
https://www.e-junkie.com/ecom/gb.php......accept-charset="UTF-8">"[/code] to [code]"<form name="pay_online" action="
https://www.e-junkie.com/ecom/gb.php......accept-charset="UTF-8" onsubmit="return validate_form ( );">"[/code]
and I added this script:
[code]<script language="javascript" type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.pay_online.os0.value == "" )
{
alert ( "Please provide your account number." );
valid = false;
}
return valid;
}
//-->
</script>[/code]