Hi I am using jQuery JavaScript Library v1.10.2
and jQuery Validation Plugin 1.11.1
and get the above error.
Code
$.validator.addMethod("fnType", function (value, element) {
if (element.value == "-1") { return false; } else {return true;}
}, "Please select Type");
The rest of the code is for jquery validation. The above code is inside $(document).ready
and within that inside $("#button").click
.
Note: I was using jQuery JavaScript Library v1.4.4
earlier and upgraded to these versions to use jquery validate. I am stuck with this from morning. Please help/advise.
EDIT: Here is the complete code
$(document).ready(function () {
OnPageLoad();
$("#ctl00_MainContentHolder_SubmitButton").click(function () {
ValidatePage();
if ($("#aspnetForm").valid()) {
if (FormValidation()) {
__doPostBack("Submit", "");
}
}
});
});
function ValidatePage() {
$.validator.addMethod("fnType", function (value, element) {
if (element.value == "-1") { return false; } else {return true;}
}, "Please select Type");
$("#aspnetForm").validate({
ignore:":hidden",
rules:
{
<%=Type.UniqueID %>: { required: true, fnType:true },
},
messages:
{
<%=Type.UniqueID %>:{ required: "Type is required" },
},
errorPlacement: function(error, element) {
error.appendTo('#ctl00_MainContentHolder_errorLabelTop');
},
wrapper: 'li'
});
}
In the master page I have these in the same order
<script type="text/javascript" src="../Script/JQuery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../Script/JQuery/jquery.validate.js"></script>
<script type="text/javascript" src="../Script/CustomScript/CustomScript.js"></script>
EDIT: Here is the HTML code
<table>
<tr>
<td colspan="2">
<label id="errorLabelTop" runat="server" class="ResponseText"></label>
</td>
</tr>
<tr>
<td style="width:130px;">
Scheme Type<span class="RedMainText" style="font-size:12px;"><sup>*</sup></span>
</td>
<td>
<select id="schemeType" runat="server" class="InputText" >
<option value="-1">--Select--</option>
<option value="Home3">Home 3 Monthly</option>
<option value="Home6">Home 6 Monthly</option>
<option value="Practice3">Practice 3 Monthly</option>
<option value="Practice6">Practice 6 Monthly</option>
</select>
</td>
</tr>
</table>