Share via E-Mail
Share on Twitter
Share on Facebook
E-junkie Blog
E-junkie FaceBook Page
E-junkie @ Twitter

E-junkie Ecommerce Forums » E-junkie Discussions

Tag Cloud for this topic:

Make Variant Information Required



trymes
member
Posts: 13


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]


#
POSTED ON: September 17, 2008 @ 13:30 GMT -7




E-junkieChef
E-Junkie Crew
Posts: 936


The form submit is a "backup" scenario for when the user has JS disabled or if you don't have box.js included in your page.

So, the primart piece of code which triggers the cart is the EJEJC_lc function which is called by the onClick event of the button included in the form.

Check out the site mentioned at http://www.e-junkie.com/bb/topic/2793#post7437 .. they seem to have done that very well.


#
POSTED ON: September 18, 2008 @ 13:58 GMT -7


You must be logged in to make a post. Please click here to login.

30 Day Money Back Guarantee
PayPal Certified Integration
Slam the Online Scam