javascript:
$(document).ready(function () {
if ($('#txt2').val() == '') {
ValidatorEnable($('#rfvtxt')[0], true);
} else
ValidatorEnable($('#rfvtxt')[0], false);
$('#txt2').change(function () {
if ($('#txt2').val() =='') {
ValidatorEnable($('#rfvtxt')[0], true);
} else
ValidatorEnable($('#rfvtxt')[0], false);
});
});
function validatePage() {
var flag = Page_ClientValidate("aaa");
return flag;
}
html:
<asp:RequiredFieldValidator runat="server" ID="rfvtxt" ControlToValidate="TXT" ErrorMessage="*" ValidationGroup="aaa" Enabled="false"></asp:RequiredFieldValidator>
<asp:Button runat="server" OnClick="Unnamed_Click" OnClientClick="javascript:return validatePage();"/>
cs.
Page.Validate();
if (!Page.IsValid)
{
return;
}
寫成function做法
http://techbrij.com/client-side-validation-using-asp-net-validator-controls-from-javascript
沒有留言:
張貼留言