Is there anyway I can force a maximum or minimum character length in a field in the checkout?
v7 and earlier
These instructions are based on setting the 'Fax Number' field in the invoice to have a minimum of 6 and a maximum of 10 characters:
Put this code into the <head> section of the overall layout template you are using for the checkout phase. This will be specified in 'Design | Options | Layouts'. Enter the code just before the </head>:
Code:-----------------------------------------------------
<script Language="JavaScript">
<!--
function Length_TextField_Validator()
{
if ((document.forms[0].INVOICEFAX.value.length < 6) || (document.forms[0].INVOICEFAX.value.length > 10))
{
// Build alert box message showing how many characters entered
mesg = "You have entered " + document.forms[0].INVOICEFAX.value.length + " character(s)\n"
mesg = mesg + "Valid entries are between 6 and 10 characters.\n"
mesg = mesg + "Please verify your input and submit again."
alert(mesg);
// Place the cursor on the field for revision
document.forms[0].INVOICEFAX.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}
-->
</script>
-----------------------------------------
Then open Act_Order01.html and locate the line that reads:
<input type=SUBMIT name=ACTION value="NETQUOTEVAR:NEXTBUTTON">
Edit this so it reads:
<input type=SUBMIT name=ACTION value="NETQUOTEVAR:NEXTBUTTON" onClick="return (Length_TextField_Validator());">
v7 and earlier
These instructions are based on setting the 'Fax Number' field in the invoice to have a minimum of 6 and a maximum of 10 characters:
Put this code into the <head> section of the overall layout template you are using for the checkout phase. This will be specified in 'Design | Options | Layouts'. Enter the code just before the </head>:
Code:-----------------------------------------------------
<script Language="JavaScript">
<!--
function Length_TextField_Validator()
{
if ((document.forms[0].INVOICEFAX.value.length < 6) || (document.forms[0].INVOICEFAX.value.length > 10))
{
// Build alert box message showing how many characters entered
mesg = "You have entered " + document.forms[0].INVOICEFAX.value.length + " character(s)\n"
mesg = mesg + "Valid entries are between 6 and 10 characters.\n"
mesg = mesg + "Please verify your input and submit again."
alert(mesg);
// Place the cursor on the field for revision
document.forms[0].INVOICEFAX.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}
-->
</script>
-----------------------------------------
Then open Act_Order01.html and locate the line that reads:
<input type=SUBMIT name=ACTION value="NETQUOTEVAR:NEXTBUTTON">
Edit this so it reads:
<input type=SUBMIT name=ACTION value="NETQUOTEVAR:NEXTBUTTON" onClick="return (Length_TextField_Validator());">