Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  40] [ 6]  / answers: 1 / hits: 25400  / 11 Years ago, tue, december 24, 2013, 12:00:00

I know there are loads of questions out there about this but I can't get this to work for the life of me. I have tried several solutions including this, the second answer here and this, and I can't get the required message to appear. The form still submits when the ckeditor field is empty.



I looked at the documentation here and am able to pass the contents of the editor to an alert but am not experienced enough to know how to integrate this with the validation plugin. I've spent so much time on this - can anyone please help?



Here is my current code, and I created a fiddle: http://jsfiddle.net/BmZ93/1/



     $('#add-job').validate({
rules: {
editor1: {
required: function()
{
CKEDITOR.instances.editor1.updateElement();
}
}
},
messages: {
Job_Title: Required,
Job_Location: Required,
jobid: Required,
Job_Cat: Required,
editor1: Required
}
});

More From » jquery

 Answers
5

Here it is update your code with this



http://jsfiddle.net/rohanppatil/BmZ93/8/



$(document).ready(function() {
$('#add-job').validate({
ignore: [],
rules: {
editor1: {
required: function()
{
CKEDITOR.instances.editor1.updateElement();
}
}
},
messages: {
Job_Title: Required,
Job_Location: Required,
jobid: Required,
Job_Cat: Required,
editor1: Required
},
/* use below section if required to place the error*/
errorPlacement: function(error, element)
{
if (element.attr(name) == editor1)
{
error.insertBefore(textarea#editor1);
} else {
error.insertBefore(element);
}
}
});
});


Hope this will work I tested this in JSFIDDLE working fine


[#73563] Monday, December 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;