[英]HTML form skips required fields
When I press submit on my HTML code I get access to the javascript even if I haven't entered the required field "Email". 当我在HTML代码上按Submit时,即使没有输入必填字段“ Email”,我也可以访问javascript。 But I see the litte "you need to fill this" popup for 0.5 seconds just before it sends me to the script.
但是在将我发送到脚本之前,我看到0.5秒钟的弹出窗口“您需要填充此内容”。 What do I need to do?
我需要做什么? Seems like it's a problem in jquery maybe?
好像这是jquery中的问题? Haris.
哈里斯
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputEmail" class="col-sm-3 control-label">Epost :</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="inputEmail" placeholder="Epost" required="required">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button type="submit" href="javascript:;" class="simpleCart_checkout">
<img src="/images/bla.png" alt="Kort">
</button>
</div>
</div>
</form>
this form is in the checkout. 此表格在结帐处。 At the bottom (payson image)
在底部(佩森图像)
Called javascript: 称为javascript:
simpleCart({
currency: "SEK",
checkout: {
type: "SendForm",
url: "http://bla.com/checkout.php",
method: "POST",
currency: "SEK"
},
shippingCustom: function () {
if (simpleCart.total() > 4500) {
return 0;
} else {
return 0;
}
},
cartStyle: "table",
cartColumns: [
/* Picture (same for every product right now) */
/* Name */
{ attr: "name", label: "Produkt" },
{ view: "decrement", label: "Minska" },
{ attr: "quantity", label: "Kvantitet" },
{ view: "increment", label: "Höj" },
/* Price */
{ attr: "price", label: "Pris", view: 'currency' },
{ attr: "total", label: "SubTotal", view: 'currency' },
/* Remove */
{ view: "remove", text: "Ta bort", label: false }
]
});
simpleCart.bind('beforeCheckout', function (data) {
data.email = document.getElementById("inputEmail").value;
});
try to replace this line: 尝试替换此行:
<input type="email" class="form-control" id="inputEmail" placeholder="Epost" required="required">
with this: 有了这个:
<input type="email" class="form-control" id="inputEmail" placeholder="Epost" required />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.