我想在几页中用bootstrap popover替换js windows,但我有两个问题,我找不到任何解决方案。
首先,如果我点击按钮显示弹出框,则会直接触发必填字段。即使我填写了“xx是必填字段”的消息,也会显示。
其次,当我尝试保存我的数据时。每个字段都包含一个额外的字符“,”。因此,如果我在代码后面的代码中放入10,则我的字段值为“10”,
感谢您的帮助:)
我的代码:
var orderItem = new Orders();
orderItem.userPurchased=body.userId;
//for each products item, push it to orderItem.products
body.products.forEach(function(product,index)
{
orderItem.products.push({
product: product.product,
size: product.size,
quantity: product.quantity,
subTotal: product.subTotal
});
});
orderItem.totalQuantity=body.totalQuantity;
orderItem.totalPrice=body.totalPrice;
orderItem.otherShipAd=body.customAdd;
orderItem.modeOfPayment=body.modeOfPayment;
Orders.save(function (err, result) {
if (err) throw err;
});
<asp:Button ID="btnAdd" runat="server" Text="add" CssClass="btn btn-info"data-toggle="popover" data-placement="top" title="add something" ValidationGroup="vgAdd" />
<div id="testBox" class="hide">
<asp:ValidationSummary ID="vsTest" runat="server" ValidationGroup="vgAdd" DisplayMode="BulletList" ShowMessageBox="false" ShowSummary="false" />
<div class="row">
<div class="form-group col-sm-6">
<asp:Label ID="lblPrice" runat="server" Text="price" AssociatedControlID="txtPrice" CssClass="control-label"></asp:Label>
<div class="input-group">
<span class="input-group-addon">$</span>
<asp:TextBox ID="txtPrice" runat="server" CssClass="form-control" MaxLength="12"></asp:TextBox>
</div>
<asp:CompareValidator ID="cvPrice1" runat="server" Display="None" ValidationGroup="vgAdd" ControlToValidate="txtPrice"
ErrorMessage="price is invalid." ValueToCompare="0" Type="Double" Operator="GreaterThan"></asp:CompareValidator>
<asp:CompareValidator ID="cvPrice" runat="server" Display="None" ValidationGroup="vgAdd" ControlToValidate="txtPrice"
Type="Double" Operator="DataTypeCheck" ErrorMessage="price is invalid."></asp:CompareValidator>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ValidationGroup="vgAdd" ControlToValidate="txtPrice"
ErrorMessage="Default price is a required field." SetFocusOnError="True" Display="Dynamic" />
</div>
<div class="form-group col-sm-6">
<asp:Label ID="lblDesc" runat="server" Text="Description" AssociatedControlID="txtDesc" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtDesc" runat="server" CssClass="form-control" TextMode="MultiLine" MaxLength="255"></asp:TextBox>
</div>
</div>
<div class="clearfix">
<asp:Button ID="btnSave" runat="server" ValidationGroup="vgAdd" CausesValidation="true"
CssClass="btn btn-primary pull-right"
OnClick="btnSaveTest_Click" Text="Save" />
</div>
</div>
答案 0 :(得分:0)
要修复第一个问题,您需要从ValidationGroup="vgAdd"
删除#btnAdd
;单击此按钮时,您不想验证表单。
关于第二个 - 你的html代码中没有什么可以附加逗号。你必须在后端代码或javascript中有一些东西。我建议你从单击按钮#btnSave
的时候开始调试 - 首先是javascript,然后是代码。