[英]validate CKEditor with jQuery Validation plugin
how to validate CKeditor with jQuery validation plugin. 如何使用jQuery验证插件验证CKeditor。
This is my code 这是我的代码
<script type="text/javascript">
$(document).ready(function(){
$("#newpost").validate({
debug: false,
rules: {
title: "required",
cat_id: "required",
editor1:"required"
},
messages: {
title: " Title name cannot be blank.",
cat_id: " Please select a category.",
editor1: " Post keywords cannot be blank."
},
submitHandler: function(form) {
// do other stuff for a valid form
$.post('new_post.php', $("#newpost").serialize(), function(data) {
$('#msgw').html(data);
});
}
});
});
</script>
PHP code: PHP代码:
<?php
include ('../db.php');
$title = mysql_real_escape_string($_POST['title']);
$editor1 = $_POST['editor1'];
$date= date("Y-m-d");
$cat_id = mysql_real_escape_string($_POST['cat_id']);
$qu = mysql_query("INSERT INTO blogposts(title,post,date,catid)VALUES ('".$title."','".$editor1."','".$date."','".$cat_id."')") or die (mysql_error());
?>
problem is it dosent even post the contain in the editor. 问题是它甚至没有在编辑器中发布包含内容。 how can i fix this problem. 我该如何解决这个问题。 thank you. 谢谢。
I have added this code below: 我在下面添加了以下代码:
CKEDITOR.instances.pdetails.updateElement(); CKEDITOR.instances.pdetails.updateElement();
pdetails is the name of your textarea. pdetails是您的文本区域的名称。 And when you try to submit your form and print out the the textarea: 当您尝试提交表单并打印出文本区域时:
$pdetails = $_POST['pdetails']; $ pdetails = $ _POST ['pdetails'];
print $pdetails; 打印$ pdetails;
make sure it has a value before you have tested it. 在测试之前,请确保它具有值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.