我有一个不应该为空的文本框,所以我在它旁边放置了一个必需的验证控件。我还有一个javascript 确认框,询问用户是否确定提交信息。
问题是确认首先出现,然后验证才开始。我想反过来。我希望首先进行验证。如果没有更多错误,则询问用户是否确定提交信息。
编辑
这是标记
<asp:LinkButton ID="_lnkAddUpdate" runat="server" CausesValidation="True" OnClientClick = "return ConfirmAddEdit(this.id)"
CommandName="Update"></asp:LinkButton>
<asp:TextBox ID="_tbLocationName" runat="server" Text= '<%# Eval("LocationName") %>'/>
<asp:RequiredFieldValidator ID="reqLocationName" runat="server" ErrorMessage="Location name cannot be empty string." Text = "*" ControlToValidate = "_tbLocationName" />
这是javascript
function ConfirmActive(id) {
var action = document.getElementById(id).innerHTML;
var r = confirm("Are you sure you want to " + action + " this location?");
if (r == false) {
return false;
}
}
感谢您的帮助。