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

Make Custom Text Field Required???

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 05-05-2013, 07:55 AM
 
stonezafu stonezafu is offline
 

Member
  
Join Date: Dec 2012
Posts: 18
 

Default Re: Make Custom Text Field Required???

Robert

Reading your question above & other forum members' advice helped me solve a problem I had with a client's site: to collect more detail about hamper delivery requirements for a holiday cottage. I copied your solution of using a custom field and validating it to ensure it's not empty.

In solving my problem, I think I have a useful lead on yours.

The code I used to make sure the input boxes are not completely empty is the following javascript:

<snippet>
if (document.getElementById('po1').value.length < 1) { alert('Please specify your Arrival Date'); return false;
}
if (document.getElementById('po2').value.length < 1) { alert('Please specify the Cottage Name'); return false;
}
else return true;

</snippet>

To be clear, you'll want to change the 'po' numbers to 'po9' and 'po8' respectively, and change the alert message to something like 'Please insert Date' and 'Please insert Client Name' as appropriate.

I probably wouldn't choose to add round brackets _within_ the Alert itself [e.g. Client(s) Name] - call it cowardice on my part! It'd likely be OK but it's only an alert after all. Who needs excellent grammar at that point?

PM me if that isn't clear enough for you to know how to alter & insert it for your site.

John
__________________
Two client sites: 4.4.4 and 4.5.5
Coding since 1981. Using X-Cart since 2012
Reply With Quote
  #12  
Old 05-07-2013, 09:37 AM
 
pifemaster pifemaster is offline
 

Member
  
Join Date: Sep 2003
Posts: 14
 

Default Re: Make Custom Text Field Required???

Quote:
Originally Posted by stonezafu
Robert

Reading your question above & other forum members' advice helped me solve a problem I had with a client's site: to collect more detail about hamper delivery requirements for a holiday cottage. I copied your solution of using a custom field and validating it to ensure it's not empty.

In solving my problem, I think I have a useful lead on yours.

The code I used to make sure the input boxes are not completely empty is the following javascript:

<snippet>
if (document.getElementById('po1').value.length < 1) { alert('Please specify your Arrival Date'); return false;
}
if (document.getElementById('po2').value.length < 1) { alert('Please specify the Cottage Name'); return false;
}
else return true;

</snippet>

To be clear, you'll want to change the 'po' numbers to 'po9' and 'po8' respectively, and change the alert message to something like 'Please insert Date' and 'Please insert Client Name' as appropriate.

I probably wouldn't choose to add round brackets _within_ the Alert itself [e.g. Client(s) Name] - call it cowardice on my part! It'd likely be OK but it's only an alert after all. Who needs excellent grammar at that point?

PM me if that isn't clear enough for you to know how to alter & insert it for your site.

John
John - YOU ARE THE MAN!!!!

I was able to use your code (with the needed adjustments) and finally get the validation to work on each of the products where I use the text input fields.

Thank you very very much.
__________________
Thank you,
Robert Pfeifer
www.pifemaster.com
Xcart Gold V 4.6.0
Reply With Quote
  #13  
Old 05-07-2013, 10:19 AM
 
stonezafu stonezafu is offline
 

Member
  
Join Date: Dec 2012
Posts: 18
 

Default Re: Make Custom Text Field Required???

Robert

That's excellent news. Glad to be able to help

Cheers, John
__________________
Two client sites: 4.4.4 and 4.5.5
Coding since 1981. Using X-Cart since 2012
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 11:25 AM.

   

 
X-Cart forums © 2001-2020