![]() |
Make Text Option a Required Field
I have added a text box in my product options. I need to make the customer type something in the box before it's added to the cart.
In other words, we cannot process the order if the text box is blank for that product. Thanks |
My own answer
So anyway, after no resopnses on the board I tried a million combinations of validation script until something worked.
Heres what I came up with so someone else doesn't have to go through the monkey business that I had to. Code:
if (document.getElementById('po42').value == "") Just replace po42 with po and the index of your product option. Replace the alert with whatever you would like to say. |
Re: Make Text Option a Required Field
where do i insert this code?
|
Re: Make Text Option a Required Field
Thanks for posting this Tabasco addict
It works like a charm. ( using 4.1.11) I had been screwing around with the same problem for the last hour or so before I found your code. leorulz if you are still wondering where to put this code it goes in the product options section. When you are adding product options to your product at the bottom of the page you will see a box titled Validation script ( Javascript) put it there. best Scott V fotodog13 4.1.11 gold apache |
Re: Make Text Option a Required Field
something else that seems to work (4.2.x)
Code:
if (product_option('Name of your text option').value == '') |
Re: Make Text Option a Required Field
Ok, Thank you.
I did somethink like this before: var obj = product_option("Line1"); if(obj.value.length<1) { alert("'Line1' Length is '"+obj.value.length+"' Text Lines fields can not be empty''"); obj.focus(); return false; } return true; But we have hundreds of products what might require same validation of more then in text line. Some thing like: Line1, Line2, Line3... In additon if you try to add our product to shopping cart and them edit (in cart.php) page x-cart open pop-up and above validation script not working. Did anyone tried it before in cart.php page. thank you. Quote:
|
Re: Make Text Option a Required Field
Thanks for posting tobasco-addict, very useful code!
Darren |
Re: Make Text Option a Required Field
Anyone know how to show the required text field on the category product list? Even with validation on the field working properly, customers can add products without completing the text field as long as they don't go to the actual product page. Any solution or ideas would be appreciated!
P.S. How do I change my display name to something OTHER than my personal e-mail =\ |
All times are GMT -8. The time now is 11:25 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.