How to implement Jquery Validation .I have use this code but not implememnt properly.
$(document).ready(function () {
$("#result-form").validate(); // intialize plugin
// presumably, this would be called after you dynamically create the new elements
$('input[type="text"]').each(function () {
$(this).rules('add', {
required: true,
digits: true,
messages: {
required: " Please enter a score!",
digits: " Please only enter numbers!"
}
});
});
});
In button click .I want to implement this code here.
$("#btnSend").click(function (e) {
var toEmail = $.trim($("#txtTo").val());
var body = $.trim($("#txtBody").val());
e.preventDefault();
var reportManagement = {
toEmail: $.trim($("#txtTo").val()),
body: $.trim($("#txtBody").val())
};

Jenith ThakkarRank #789 · 2.9K reputationPosted Sep 30, 2020, 9:20 PM EDT
if you're not using form then do it in custom way
set span after inputs
and check using jquery if value is blank then show that span and return false
Sachin SinghRank #66 · 26.2K reputationPosted Sep 30, 2020, 7:33 AM EDT
Amit KumarRank #459 · 5.4K reputationPosted Sep 30, 2020, 8:40 PM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Sep 30, 2020, 9:34 PM EDT