如何在电子商务表格上要求最低数量
How Can I require a Minimum Quantity on an e-commerce Form?
如何在电子商务表单上要求最低数量?
我使用的是Mal‘s Cart表格,有价格优惠,但我想要求我的客户至少有15个单位。
我尝试将此添加到Serif WebPlus X6中现有的javascript验证函数中,但它不起作用。:
if('qty1'>=15) {return true;} else{ alert("Please enter Minimum Order of 15.") return false;}
这是完整的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home</title>
<meta name="Generator" content="Serif WebPlus X6 (14.0.0.020)">
<meta name="viewport" content="width=960">
<script type="text/javascript">
function validate_ys-12x18-1c2s( form )
{
//Custom Validation Steps
if( ltrim(rtrim(form.elements['qty1'].value,' '),' ')=="" ) { alert("Please enter some text"); form.elements['qty1'].focus(); return false; }
if( isNaN( parseInt( form.elements['qty1'].value ) ) ) { alert("Please enter a number"); form.elements['qty1'].focus(); return false; }
if('qty1'>=15) {return true;} else{ alert("Please enter Minimum Order of 15.") return false;}
//Custom Validation for element
return true;
}
</script>
<style type="text/css">
body{margin:0;padding:0;}
.Button1,.Button1:link,.Button1:visited{background-image:url('wpimages/wp5325eb44_06.png');background-position:0px 0px;text-decoration:none;display:inline-block;background-color:transparent;border:none 0px;padding:0;}
.Button1:focus{outline-style:none;}
.Button1:hover{background-position:0px -45px;}
.Button1 span,.Button1:link span,.Button1:visited span{color:#ffffff;font-family:"Futura LtCn BT",sans-serif;font-weight:normal;text-decoration:none;text-align:center;text-transform:none;font-style:normal;left:9px;top:5px;width:127px;height:35px;font-size:27px;display:block;position:absolute;cursor:pointer;}
.Button1:hover span{color:#000000;left:18px;width:110px;}
.Button1:active span{color:#000000;left:18px;width:110px;}
</style>
</head>
<body text="#000000" style="background:#ffffff; height:1000px;">
<div style="background-color:transparent;margin-left:auto;margin-right:auto;position:relative;width:960px;height:1000px;">
<form id="ys-12x18-1c2s" onsubmit="return validate_ys-12x18-1c2s(this)" action="http://12.aitsafe.com/cf/addmulti.cfm" method="post" target="_self" style="margin:0;position:absolute;left:16px;top:13px;width:240px;height:125px;">
<input type="hidden" name="currency" value="">
<input type="hidden" name="product1[]" value="Yard Signs 12"x18" -1 Color-2 Side">
<input type="hidden" name="scode1" value="YdSgn-12x18-1c-2s">
<input type="hidden" name="price1" value="104.25">
<input type="hidden" name="discountpr1" value="24,6.99:25,4.99:50,3.09:50,2.29:100,2.09:250,1.99:500,1.89:9001,1.79">
<input type="hidden" name="return" value="www.MYDOMAIN.com/index.html">
<input type="hidden" name="lg" value="0">
<input type="hidden" name="userid" value="MYNUMBER">
<img src="wpimages/wpe73c68aa_06.png" border="0" width="60" height="20" title="" alt="QUANTITY " style="position:absolute;left:72px;top:25px;">
<input type="text" name="qty1" value="15" style="position:absolute; left:147px; top:25px; width:50px;">
<div style="position:absolute;left:62px;top:58px;width:145px;height:45px;"><button type="submit" id="btn_311" class="Button1" style="width:145px;height:45px;"><span>ADD TO CART</span></button></div>
</form>
<script type="text/javascript" src="wpscripts/jsValidation.js"></script>
</div>
</body>
</html>
您将字符串与数字15进行比较,而不是与标记为"qty1"的字段中的值进行比较。看看上面几行中的条件检查。你可能需要这样的东西:
if( parseInt( form.elements['qty1'].value ) >=15) {return true;}
else{ alert("Please enter Minimum Order of 15."); return false;}
相关文章:
- 动态分配GA增强型电子商务跟踪器
- 在电子商务结账过程中显示特定于上下文的错误
- 如何在电子商务表格上要求最低数量
- 谷歌分析中没有电子商务跟踪
- Bootstrap v2.3.2电子商务结账页面中的奇数对齐
- 谷歌分析电子商务跟踪仅收到2个项目中的3个
- 如何创建电子商务网站
- 是否可以在使用电子商务扩展时将自定义变量发送到谷歌分析
- 谷歌分析 API 电子商务数据
- “未捕获的类型错误:无法读取未定义的属性'电子商务'”的可能原因
- 如何从 Odoo 8 的前端删除 Powered by Odoo #1 开源电子商务页脚
- NodeJS - 任何电子商务解决方案
- 如何在Magento电子商务网站版本1.3.2.4中包含带有脚本的自定义js文件
- 使用javascript(a/b-test)对电子商务页面进行排序
- 使用滚动事件正确实现GA增强型电子商务addImpression
- 如何仅使用javascript对电子商务网站进行索引
- 如何水平显示我格式化的JSON数据,类似于电子商务网站
- 根据商品价格对电子商务网站上的商品进行排序
- 如何计算产品在电子商务网站上的排名/位置
- 正在分析电子商务数据以推送到谷歌标签管理器的数据层