Commit 438c3257 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

TinyMCE's `<textarea>` now also subject to validation.

Remove validation messages properly, using bootstrap-validator API
parent 81c8a960
......@@ -336,8 +336,6 @@ var QfqNS = QfqNS || {};
n.QfqForm.prototype.submit = function () {
if (this.form.validate() !== true) {
this.form.$form.validator('validate');
var element = this.form.getFirstNonValidElement();
if (element.hasAttribute('name')) {
var tabId = this.bsTabs.getContainingTabIdForFormControl(element.getAttribute('name'));
......@@ -346,10 +344,15 @@ var QfqNS = QfqNS || {};
}
}
// Since we might have switched the tab, re-validate to hightlight errors
this.form.$form.validator('update');
this.form.$form.validator('validate');
var alert = new n.Alert("Form is incomplete.", "warning");
alert.show();
return;
}
// First, remove all validation states, in case a previous submit has set a validation state, thus we're not
// stockpiling them.
this.clearAllValidationStates();
......@@ -705,8 +708,7 @@ var QfqNS = QfqNS || {};
n.QfqForm.prototype.clearAllValidationStates = function () {
$('.has-warning,.has-error,.has-success,.has-danger').removeClass("has-warning has-error has-success" +
" has-danger");
this.form.$form.validator('reset');
$('[data-qfq=validation-message]').remove();
};
......
......@@ -343,11 +343,13 @@
<label for="notes-editor" class="control-label">Notes</label>
</div>
<div class="col-md-6">
<textarea id="notes-editor" class="qfq-tinymce"
data-control-name="notesField" name="notesField" required>
</textarea>
<textarea id="notes-editor" class="form-control qfq-tinymce"
data-control-name="notesField" name="notesField" required></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
......@@ -850,7 +852,9 @@
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/validator.min.js"></script>
<script src="../js/jqx-all.js"></script>
<script src="../js/globalize.js"></script>
<script src="../js/tinymce.min.js"></script>
......@@ -859,6 +863,8 @@
<script type="text/javascript">
$(function () {
/* All textareas having the class `.qfq-tinymce` are made hidden by tinyMCE, ergo, we have to include them specifically in the bootstrap validator. */
//$.fn.validator.Constructor.INPUT_SELECTOR = ':input:not([type="submit"], button):enabled';
$("#subrecord_adresse").jqxDataTable(
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment