[英]validate CKEditor with jQuery Validation plugin
如何使用jQuery驗證插件驗證CKeditor。
這是我的代碼
<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代碼:
<?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());
?>
問題是它甚至沒有在編輯器中發布包含內容。 我該如何解決這個問題。 謝謝。
我在下面添加了以下代碼:
CKEDITOR.instances.pdetails.updateElement();
pdetails是您的文本區域的名稱。 當您嘗試提交表單並打印出文本區域時:
$ pdetails = $ _POST ['pdetails'];
打印$ pdetails;
在測試之前,請確保它具有值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.