以下java脚本是提示弹出消息,
function TrimString(sInString) {
sInString = sInString.replace(/^\s+/g, ""); // strip leading
return sInString.replace(/\s+$/g, ""); // strip trailing
}
function ValidateEmptyCriteria(form) {
var bolAllEmpty = true;`enter code here`
for (var i = 0; i < form.length; i++) {
// alert(i);
//alert(form.elements[i].type);
if (form.elements[i].type == 'text') {
if (TrimString(form.elements[i].value) != "") {
bolAllEmpty = false;
break;
}
}
if (form.elements[i].type == 'select-one') {
if (form.elements[i].selectedIndex > 0) {
bolAllEmpty = false;
break;
}
}
if (form.elements[i].type == 'checkbox') {
if ((form.elements[i].checked) == true) {
bolAllEmpty = false;
break;
}
}
}
if (bolAllEmpty) {
return ConfirmEmptyCriteriaSearch();
}
else return (true);
}
function ConfirmEmptyCriteriaSearch() {
var agree = confirm("No search string is entered. Click [0K] to show all records.");
if (agree)
return true;
else
return false;
}
function ValidateEmptyCriteriaExcludeDate(form) {
var bolAllEmpty = true;
for (var i = 0; i < form.length; i++) {
// alert(i);
//alert(form.elements[i].type);
if (form.elements[i].type == 'text') {
if (TrimString(form.elements[i].value) != "" && form.elements[i].id != 'txtFromDate' && form.elements[i].id != 'txtToDate') {
bolAllEmpty = false;
break;
}
}
if (form.elements[i].type == 'select-one') {
if (form.elements[i].selectedIndex > 0) {
bolAllEmpty = false;
break;
}
}
}
if (bolAllEmpty) {
return ConfirmEmptyCriteriaSearch();
}
else return (true);
}
<script language="javascript" type="text/javascript" src="<%=Page.ResolveUrl("~/Control/ValidateEmptyCriteria.js")%>"></script>
以下是按钮代码,
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr class="clsTBRow" style="height: 8px;">
<td style="width: 10px;" />
<td style="width: 150px;" />
<td />
</tr>
<tr class="clsTBRow">
<td>
</td>
<td>
Card Type Name :
</td>
<td>
<asp:TextBox ID="txtCardTypeName" runat="server" MaxLength="50" Width="200px" />
</td>
</tr>
<tr class="clsTBRow">
<td>
</td>
<td>
Description :
</td>
<td>
<asp:TextBox ID="txtDescription" runat="server" Width="200px" MaxLength="100" />
</td>
</tr>
<tr class="clsTBRow" style="height: 50px; vertical-align: middle;">
<td colspan="2">
</td>
<td>
<span id="spanCmdSubmit" runat="server">
<asp:Button ID="CmdSubmit" runat="server" Text="Search" /> </span> <span id="spanCmdReset"
runat="server">
<asp:Button ID="CmdReset" runat="server" Text="Reset" /></span>
</td>
</tr>
</table>