Skip to content

TagSpaces is an offline, open source, document manager with tagging support

implementing the new validator in the tag create dialog

Ilian665e5c14aff4
diff --git a/data/index.html b/data/index.html
index 4f7897b84..959016446 100644
--- a/data/index.html
+++ b/data/index.html
@@ -414,11 +414,14 @@ can be found in the LICENSE file.
<h4 data-i18n="ns.dialogs:tagOperationTitle">Tag operation on multiple files</h4>
</div>
<div class="modal-body form">
- <div class="form-group">
- <label class="control-label" for="tags" data-i18n="ns.dialogs:tagOperationTag">Tags</label>
- <input class="form-control" type="text" name="tags" id="tags" autocomplete="off" data-i18n="[placeholder]ns.dialogs:tagOperationTagsPlaceholder"/>
- <p class="help-block" data-i18n="ns.dialogs:editTagNamesRestrictionsHelp">Tags should have a minimum length of 2 characters and should not contain special characters such as spaces, #, / ,\ and other.</p>
- </div>
+ <form role="form" data-toggle="validator">
+ <div class="form-group">
+ <label class="control-label" for="tags" data-i18n="ns.dialogs:tagOperationTag">Tags</label>
+ <input class="form-control" type="text" name="tags" id="tags" autocomplete="off"
+ data-i18n="[placeholder]ns.dialogs:tagOperationTagsPlaceholder"/>
+ <p class="help-block" data-i18n="ns.dialogs:editTagNamesRestrictionsHelp">Tags should have a minimum length of 2 characters and should not contain special characters such as spaces, #, / ,\ and other.</p>
+ </div>
+ </form>
</div>
<div class="modal-footer">
<button id="cleanTagsButton" class="btn btn-danger pull-left" data-dismiss="modal" aria-hidden="true" data-i18n="ns.dialogs:tagOperationCleanTags">Clean Tags</button>
@@ -510,11 +513,14 @@ can be found in the LICENSE file.
<h4 data-i18n="ns.dialogs:addTagsToGroupTitle">Add tags to tag group</h4>
</div>
<div class="modal-body form">
- <div class="form-group">
- <label class="control-label" for="newTagTitle" data-i18n="ns.dialogs:addTagsToGroupTags">Tags</label>
- <input class="form-control" type="text" name="newTagTitle" id="newTagTitle" data-i18n="[placeholder]ns.dialogs:addTagsToGroupTagsPlaceholder" />
- <p class="help-block" data-i18n="ns.dialogs:editTagNamesRestrictionsHelp">Tags should have a minimum length of 2 characters and should not contain special characters such as spaces, #, / ,\ and other.</p>
- </div>
+ <form role="form" data-toggle="validator" id="formAddTags">
+ <div class="form-group">
+ <label class="control-label" for="newTagTitle" data-i18n="ns.dialogs:addTagsToGroupTags">Tags</label>
+ <input pattern="^([_\-\ ,A-z0-9]){2,}$" class="form-control" type="text" name="newTagTitle"
+ id="newTagTitle" data-i18n="[placeholder]ns.dialogs:addTagsToGroupTagsPlaceholder;[data-error]ns.dialogs:editTagNamesRestrictionsHelp" />
+ <p class="help-block with-errors"></p>
+ </div>
+ </form>
</div>
<div class="modal-footer">
<button class="btn cancelButton" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times fa-lg"></i></button>
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index f29ab9cb5..4abce39d7 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -439,11 +439,18 @@
function showDialogTagCreate() {
$( "#newTagTitle" ).val("");
+ $("#formAddTags").validator();
+ $('#formAddTags').on('invalid.bs.validator', function() {
+ $( "#createTagButton").prop( "disabled", true );
+ });
+ $('#formAddTags').on('valid.bs.validator', function() {
+ $( "#createTagButton").prop( "disabled", false );
+ });
+
$('#dialogTagCreate').on('shown.bs.modal', function () {
$('#newTagTitle').focus();
});
-
- $( '#dialogTagCreate' ).modal({backdrop: 'static',show: true});
+ $('#dialogTagCreate').modal({backdrop: 'static',show: true});
}
function showDialogEditTagGroup() {
@@ -471,7 +478,6 @@
$( "#tagInTreeKeyBinding" ).val(TSCORE.selectedTagData.keyBinding);
-
var $tagColorChooser = $( "#tagColorChooser" );
var $tagColor = $('#tagColor');
$tagColorChooser.simplecolorpicker({picker: false, theme: 'fontawesome'});