简体   繁体   English

如何在电子商务表格上要求最低数量?

[英]How Can I require a Minimum Quantity on an e-commerce Form?

How Can I require a Minimum Quantity on an e-commerce Form? 如何在电子商务表格上要求最低数量?

I am using a Mal's Cart form, and have a Price Break, but I want to Require my customers to have a minimum of 15 units. 我正在使用Mal的购物车表格,并且有一个价格优惠,但我想要求我的客户最少拥有15个单位。

I tried adding this to the existing javascript validate function from Serif WebPlus X6), It does not work.: 我尝试将其添加到Serif WebPlus X6的现有javascript验证函数中),它不起作用。

if('qty1'>=15) {return true;} else{ alert("Please enter Minimum Order of 15.") return false;}

Here is the full code: 这是完整的代码:

<!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&quot;x18&quot; -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&#10;" 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&nbsp;TO&nbsp;CART</span></button></div>
  </form>
  <script type="text/javascript" src="wpscripts/jsValidation.js"></script>
</div>
</body>
</html>

You're comparing a string to the number 15, not the value in the field labeled 'qty1'. 您正在将字符串与数字15进行比较,而不是标记为“ qty1”的字段中的值。 Take a look at the conditional checks in the lines above yours. 在您上方的行中查看条件检查。 You likely need something like this: 您可能需要这样的东西:

if( parseInt( form.elements['qty1'].value ) >=15) {return true;} 
else{ alert("Please enter Minimum Order of 15."); return false;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用以下代码实现我的电子商务项目的 countInStock 数量的增加或减少? - How can I implement increase or decrease quantity till countInStock of my my e-commerce project with the below code? Google 分析如何跟踪电子商务访问者的行为 - How Google analytics can track e-commerce visitors behavior 如何为我的电子商务项目乘以 reactjs? - How do I multiply for my e-commerce project with reactjs? 单击电子商务网站中的搜索按钮后,如何阻止页面重新加载? - How can I stop the page from reloading after I click on search button in my E-commerce site? Laravel中的电子商务 - E-commerce in Laravel 我正在为客户开发电子商务网站,他们如何更新商店中的商品? - I'm developing an e-commerce site for a client, how do they update items on the shop? 我应该如何为电子商务网站的结帐页面创建逻辑? - How should i create logic for checkout page for an e-commerce website? 如何在我的 React Hooks 电子商务应用程序中使用 JSON 文件作为虚拟用户的数据库? - How do I use a JSON file as a database for dummy users in my React Hooks e-commerce app? Google电子商务跟踪 - Google E-Commerce Tracking 如何使用HTML CSS设计响应式电子商务产品卡 - How to design a responsive e-commerce product card with html css
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM