Make Custom Fields Required and Validated

General ShopSite user discussion

Make Custom Fields Required and Validated

Postby sellmethemoney » Tue Dec 15, 2009 1:55 pm

Hello,

I have 3 'different' custom fields that display in my product.

I am using this code in my custom product template

<!--inserted this for multiple field-->
<input name="[-- PRODUCT.RecordNumber --]:freeopt" type=hidden
id="[-- PRODUCT.RecordNumber --]:freeopt" value="First_Name ">First Name<br>
<input name="[-- PRODUCT.RecordNumber --]:freeopt" type="text"
id="[-- PRODUCT.RecordNumber --]:freeopt" value="" size="25"><br>

<input name="[-- PRODUCT.RecordNumber --]:freeopt" type=hidden
id="[-- PRODUCT.RecordNumber --]:freeopt" value="Last_Name ">Last Name<br>
<input name="[-- PRODUCT.RecordNumber --]:freeopt" type="text"
id="[-- PRODUCT.RecordNumber --]:freeopt" value="" size="25"><br>

<input name="[-- PRODUCT.RecordNumber --]:freeopt" type=hidden
id="[-- PRODUCT.RecordNumber --]:freeopt" value="Email ">Email<br>
<input name="[-- PRODUCT.RecordNumber --]:freeopt" type="text"
id="[-- PRODUCT.RecordNumber --]:freeopt" value="" size="50"><br>


I know that in the checkout page all of them are displayed as 1 big field separated by a comma. I don't have a problem with it. However, I do need to make these fields not only required, but also to have a maximum length equal to their size: names= 25 and email= 50. Furthermore, I need to validate the email and make sure is in correct format like "justme@aol.com"


Can this be possible in ShopSite's custom templates or pages?

Thanks!

:D
sellmethemoney
 
Posts: 17
Joined: Tue Dec 15, 2009 9:00 am
Location: Chicago, IL

Postby Jim » Tue Dec 15, 2009 2:20 pm

add maxlength="25" or maxlength="50" before the size value to set the maximum character input.

You would need to have some javascript to validate that they input values but that might be hard since you are putting 6 different values into one field.

Validating email addresses can be complicated too. Probably the most you can do is validate that there is something before the @ then something before a . and something after the .
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby sellmethemoney » Wed Dec 16, 2009 1:31 pm

Hi Jim,

Thanks for the reply. I was able to set up the max length as described. I still need to come up with a javascript code that will attempt to check for the email. If I can figure it out, where do I place this javascript code? in the product custom template?

Thanks again.
sellmethemoney
 
Posts: 17
Joined: Tue Dec 15, 2009 9:00 am
Location: Chicago, IL

Postby sellmethemoney » Thu Dec 17, 2009 2:52 pm

Hello again,

I guess I take back the line where I said I don't have a problem with the custom text boxes being displayed as one big field separated by a comma in the checkout process, especially in the receipt that's emailed to the client. We certainly do care because it doesn't look right and it may be confusing to the user.

Is there a way to make this field to be displayed as multiple columns or rows?

Also, I still haven't been able to make these fields required in the begginning of the order process. Is that possible?

Thanks again!
sellmethemoney
 
Posts: 17
Joined: Tue Dec 15, 2009 9:00 am
Location: Chicago, IL


Return to User Forum

Who is online

Users browsing this forum: No registered users and 139 guests