0
我正在使用此plugin來驗證表單。我遇到的其中一個問題是其中一個文本字段是BBCode插件,因此在驗證該字段時沒有任何反應。jQuery驗證插件和自定義輸入
下,它說:Write the body of your tutorial
使用設置高亮插件,它增加了大量HTML和一個單獨的輸入框,你必須使用此代碼來獲取值
$('textarea.bbcode').sceditor('instance').val();
所以,理想情況下,我需要圖中的文字區域如何連接到jQuery的表單驗證
這裏是我的代碼:
$("#creation-form").validate({
rules: {
title: {
required: true,
maxlength: 100,
minlength: 10
},
category: "required",
body: {
required: true,
},
tags: "required"
},
messages: {
title: 'Please enter the title of your tutorial'
},
errorElement: 'div',
errorPlacement: function(error, element)
{
error.addClass('form-error');
error.insertAfter(element);
}
})
和HTML表單:
<form method="post" action="" enctype="multipart/form-data" id="creation-form">
@if(Content::hasContent('upload_tutorial'))
<div class="alert alert-info">
{{ Content::getContent('upload_tutorial') }}
</div>
@endif
@if(FormResponse::has())
<div class="box-wrapper">
<div class="box-content">
{{ FormResponse::get() }}
</div>
</div>
@endif
<div class="margin-bottom"></div>
<p>Tutorial Title</p>
<p><input type="text" name="title" class="form-control" maxlength="100" value="{{ $upload->title or "" }}"></p>
<p> </p>
<p>Tutorial Category</p>
<p><select name="category" class="form-control">
<option value="" selected>Select a category</option>
@foreach(TutorialCategory::all() as $tut)
@if(isset($upload->category) && $upload->category == $tut->name)
<option value="{{ $tut->name }}">{{ $tut->name }}</option>
@else
<option value="{{ $tut->name }}" checked>{{ $tut->name }}</option>
@endif
@endforeach
</select></p>
<p> </p>
<p>Write the body of your tutorial</p>
<p><textarea name="body" class="bbcode">{{ $upload->body or "" }}</textarea></p>
<p> </p>
<p>Add tags</p>
<input type="text" name="tags" id="tagField" class="form-control" value="{{ $upload->tags or "" }}">
<ul id="tags"></ul>
<p><b>Tags:</b>
@foreach(Tag::getTagsArray('tutorial') as $k => $tagName)
<span class="tag-name">{{ $tagName}}</span>
@endforeach
</p>
<p> </p>
<p>Select a picture</p>
<p><input type="file" name="picture" class="form-control"></p>
@if($upload != null && $upload->hasPicture())
<p> </p>
<img src="{{ $upload->getThumbnail() }}" style="max-height:150px">
@endif
<p> </p>
<button class="btn">Upload Tutorial</button>
</form>
你可以把執行的代碼的HTML?這是webforms ..我會更準確和快速的方式〜 – Teocci
這裏是執行的HTML:@Teocci https://pastebin.com/TwvNa6Vc – Ben
姆我檢查代碼和'插件',它沒有一種驗證'bbcode'' textarea'的方法。我需要一些時間來思考如何驗證它。 – Teocci