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
<form action="<a href="https://www.e-junkie.com/ecom/gb.php......accept-charset=" target="_blank">https://www.e-junkie.com/ecom/gb.php......accept-charset=</a>"UTF-8">"
to
"<form name="pay_online" action="<a href="https://www.e-junkie.com/ecom/gb.php......accept-charset=" target="_blank">https://www.e-junkie.com/ecom/gb.php......accept-charset=</a>"UTF-8" onsubmit="return validate_form ( );">"
and I added this script:
<script language="javascript" type="text/javascript"><br />
<!--<br />
<br />
function validate_form ( )<br />
{<br />
valid = true;<br />
<br />
if ( document.pay_online.os0.value == "" )<br />
{<br />
alert ( "Please provide your account number." );<br />
valid = false;<br />
}<br />
<br />
return valid;<br />
}<br />
<br />
//--><br />
</script>