[英]On button Click if texbox value is empty show alert using asp.net mvc?
在按钮btnClick
,如果用户提交带有空白MedicineName
文本字段的表单,则单击“我要提醒用户”。如果MedicineName
texbox值为空,则表示弹出而不是“隐藏”。
在我的代码中,“打开”按钮上的单击警报消息同时显示,同时弹出
$("#btnClick").click(function () {
var id = jQuery('[id$=hfCustomer]').val();
if (id == '') {
alert('MedicineNameis empty');
$("#upload3Modal").hide();
}
else {
$.get("GenericName_Bind", { ProductID: id }, function (data) {
$.each(data, function (i, v1) {
var GenID = v1.Value;
if (GenID) {
$('#hdnGenericID').val(GenID);
}
$('#txtGenericName').val(v1.Text);
});
});
}
});
HTML:
<div class="col-lg-4">
<fieldset class="form-group">
<label class="form-label" for="exampleInput">MedicineName</label>
@*@Html.TextBoxFor(model => Model.MedicineName, new { @class = "form-control", @id = "txtMedicineName", placeholder = "MedicineName" })*@
<div class="typeahead-container">
<div class="typeahead-field">
<span class="typeahead-query">
@Html.TextBoxFor(model => Model.prescriptionmanagement.MedicineName, new { @class = "form-control", @id = "txtMedicineName", placeholder = "Medicine Name", name = "d", type = "search", autocomplete = "off" })
<input type="hidden" id="hfCustomer" name="CustomerId" />
</span>
</div>
</div>
@Html.ValidationMessageFor(model => Model.prescriptionmanagement.MedicineName, null, new { @style = "color: red" })
</fieldset>
</div>
<div class="col-lg-4">
<fieldset class="form-group">
<label class="form-label" for="exampleInput">Drug Specifications</label>
<div class="tbl-cell tbl-cell-action button">
<a href="#" data-toggle="modal" id="btnClick" data-target="#upload3Modal" class="btn btn-rounded btn-block">Drug Specifications <span class="font-icon-search"></span></a>
</div>
</fieldset>
</div>
尝试模式隐藏完成功能
引导程序3
$('#upload3Modal').on('hidden.bs.modal', function () {
alert('MedicineNameis empty')
})
引导程序2.3.2
$('#upload3Modal').on('hidden', function () {
alert('MedicineNameis empty')
})
参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.