View Single Post
  #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