Quill: Is there a way to implement URL validation

Created on 13 Dec 2017  路  2Comments  路  Source: quilljs/quill

Hello

I'm trying to implement links validation to show error if user enters invalid URL for weblink and not to close creation link popup.
So how can i control link popup?

Thanks in advance.

Most helpful comment

I managed to do url validation, the code is not perfect, but works.

            var tooltipSave = quillInstance.theme.tooltip.save;

            quillInstance.theme.tooltip.save = function() {
                // overwrite save link functionality
                var url = this.textbox.value;

                if(url.indexOf('http') === -1) {
                    url = 'http://' + url;
                }

                $(this.textbox).removeClass('ql-error');
                // validate url
                if(util.validateURL(url)) {
                    tooltipSave.call(this);
                }
                else {
                    // show error in tooltip
                    $(this.textbox).addClass('ql-error');
                }
            };

All 2 comments

I managed to do url validation, the code is not perfect, but works.

            var tooltipSave = quillInstance.theme.tooltip.save;

            quillInstance.theme.tooltip.save = function() {
                // overwrite save link functionality
                var url = this.textbox.value;

                if(url.indexOf('http') === -1) {
                    url = 'http://' + url;
                }

                $(this.textbox).removeClass('ql-error');
                // validate url
                if(util.validateURL(url)) {
                    tooltipSave.call(this);
                }
                else {
                    // show error in tooltip
                    $(this.textbox).addClass('ql-error');
                }
            };

Looks like you've found a solution. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

visore picture visore  路  3Comments

splacentino picture splacentino  路  3Comments

GildedHonour picture GildedHonour  路  3Comments

eamodio picture eamodio  路  3Comments

ouhman picture ouhman  路  3Comments