i have asp text box and button control.
<asp:TextBox ID="txtFName" runat="server" CssClass="sfInputbox"></asp:TextBox>
<asp:Button runat="Server" Text="Save" ID="btnSave" OnClick="btnSave_Click"/>
i want to validate textbox using validate.js
when button is clicked. i try inside document.ready
:
var btnSave = '<%=btnSave.ClientID%>';
var txtFName = '<%=txtFName.ClientID %>';
var v = $("#form1").validate({
ignore: ':hidden',
rules: {
txtFName: { required: true }
},
messages: {
txtLinkTitle: "<br/>First Name should not be blank"
}
});
if (v.form()) {
$('#' + btnSave).attr('disabled', 'disabled');
}else
$('#' + btnSave).removeAttr('disabled');
});
But its not work.Don't suggest server side validation.Its my project demand.Thanks.
if i have understood the question, you can try
if ($("#form1").valid()) {
//do something
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.