我有一个输入字段,除非您输入/选择某些内容,否则该字段不允许您搜索。我该怎么做呢?
<input type="text" class="form-control pg-csr-customer-search CSRinputBut" aria-label="" id="CustomerSearchText" name="CustomerSearchText" value="" placeholder="Search Customer" required>
当用户点击或点击进入时,我需要显示此警告。
displayCustomerSearchMessage('<i class=\"fa fa-exclamation-circle pull-left\"></i> Sorry, missing selected Customer Id. Please make a selection from the results listing.', 'warning');
答案 0 :(得分:0)
<input type="text" name="CustomerSearchText" id="CustomerSearchText" onblur="checkTextField(this);" />
//modify following code as your need
function checkTextField(field) {
if (field.value == '') {
alert("empty!!!");
}
}
<强>更新强>
<form onsubmit="return checkTextField(this)">
function checkTextField(form) {
var text = form.CustomerSearchText.value;
if (text == '') {
return false
}
return true;
}