Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Make Text Option a Required Field

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-30-2005, 08:25 AM
  tabasco-addict's Avatar 
tabasco-addict tabasco-addict is offline
 

Newbie
  
Join Date: Apr 2005
Location: Arizona USA
Posts: 4
 

Default 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
__________________
Shawn Bulle
RedPup Productions

X-Cart ver 4.0.13
Reply With Quote
  #2  
Old 05-03-2005, 06:43 AM
  tabasco-addict's Avatar 
tabasco-addict tabasco-addict is offline
 

Newbie
  
Join Date: Apr 2005
Location: Arizona USA
Posts: 4
 

Default 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 == "") {alert('Please enter the name of the person or company the the software will be registered in.') document.getElementById('po42').focus() return false; } else { return true; }

Just replace po42 with po and the index of your product option.

Replace the alert with whatever you would like to say.
__________________
Shawn Bulle
RedPup Productions

X-Cart ver 4.0.13
Reply With Quote

The following 2 users thank tabasco-addict for this useful post:
Jenb (08-21-2013), sportsmomict (01-07-2014)
  #3  
Old 12-08-2007, 10:25 PM
 
leorulz leorulz is offline
 

Advanced Member
  
Join Date: Jul 2006
Posts: 66
 

Default Re: Make Text Option a Required Field

where do i insert this code?
__________________
version 4.4.2
www.bodyandmindspa.com/
Reply With Quote
  #4  
Old 11-07-2008, 05:30 AM
 
fotodog13 fotodog13 is offline
 

Senior Member
  
Join Date: Sep 2007
Posts: 126
 

Default 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
__________________
scott v
x cart version 4.1.8 (Unix)
Reply With Quote
  #5  
Old 11-18-2009, 07:42 AM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

Default 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 == '') { alert('Alert you want to show'); return false; } else return true;
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
  #6  
Old 03-23-2010, 11:39 AM
  Yalokin's Avatar 
Yalokin Yalokin is offline
 

Advanced Member
  
Join Date: Sep 2009
Location: New York USA
Posts: 75
 

Default 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:
Originally Posted by Warwick
something else that seems to work (4.2.x)
Code:
if (product_option('Name of your text option').value == '') { alert('Alert you want to show'); return false; } else return true;
__________________
Reply With Quote
  #7  
Old 05-24-2010, 08:06 AM
 
dmpinder dmpinder is offline
 

Advanced Member
  
Join Date: Jun 2009
Posts: 86
 

Default Re: Make Text Option a Required Field

Thanks for posting tobasco-addict, very useful code!

Darren
__________________
Darren

X-Cart Gold 4.3.1
Reply With Quote
  #8  
Old 03-08-2012, 12:37 PM
 
jeff@purelyproven.com jeff@purelyproven.com is offline
 

Newbie
  
Join Date: Feb 2010
Posts: 1
 

Default 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 =\
__________________
X-Cart Gold 4.4.5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:25 PM.

   

 
X-Cart forums © 2001-2020