I'm trying to do some form validation (one field, needs to be 15 digits and numeric only) and I have the validation working on a php page I cannot seem to use it on my e-junkie form/cart.
The meat of it is below:
<script Language="Javascript">
<!--
// The previous line hides the script from old browsers that cant interpret it
function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
function emptyvalidation(entered, alertbox)
{
// Emptyfield-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(model,"Please enter your phone model")==false) {model.focus(); return false;};
if (emptyvalidation(imei,"Please enter your 15 digit IMEI number.")==false) {imei.focus(); return false;};
if (digitvalidation(imei,15,"Your IMEI is a 15 digit number. Please enter it correctly","Your IMEI is a 15 digit number. Please enter it correctly")==false) {imei.focus(); return false;};
}
}
// The next line causes oldfashion browsers to start interpreting the code again.
//-->
</script>
It requires "onsubmit="return formvalidation(this)"" as part of the "form action" line.....this works perfectly on my php page but it doesn't appear to do anything with my e-junkie form/cart/product.
Anyone else doing forms with validation with e-junkie?