Guest User

Guest User

  • Tech Writer
  • 611
  • 126.6k

Validation implement using jquery Validation .

Sep 30 2020 11:00 AM
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())
};

Answers (4)