More in this section

Forums / General Discussions / Regular expressions for form builder text box

Regular expressions for form builder text box

5 posts, 0 answered
  1. Jörg
    Jörg  avatar
    16 posts
    Registered:
    17 Mar 2009
    23 Aug 2010
    Link to this post
    I think the new form builder is a great tool. However I miss one very important functionality.
    Almost every form will require an Email address. So I want to validate the input and make sure the user entered a valid email address. In asp.net I would use a validator.
    So either I can place validators on a form, or probably the easier solution is to being able to specify a regular expression for a text box.

    Is a feature like this planned?

    Regards
    Jörg
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Aug 2010
    Link to this post
    Hi Jörg ,

    I will add your suggestion as a request for the RC of Sitefinity 4.0.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    28 Jun 2011
    Link to this post
    Ivan,

    Can I ask a question here related to the ticket you are helping me with. I am thinking that many other people may want to know how to do this. I want to use regular expressions in my designer.js class for my BasicEditor Control. I don't think there is a way to get hold of a table that is inside the htmlField. So I am thinking the only way is to use RegEx now. The code is as follows:
    Type.registerNamespace("SitefinityWebApp.Controls");
     
    SitefinityWebApp.Controls.BasicEditorDesigner = function (element) {
        SitefinityWebApp.Controls.BasicEditorDesigner.initializeBase(this, [element]);
         
        // element
        this._htmlEditor = null;
     
        this._btnClearAll = null;
        this._btnClearAllDelegate = null;
    }
     
    SitefinityWebApp.Controls.BasicEditorDesigner.prototype = {
        /* ------------------------------ set up and tear down ----------------------- */
        initialize: function () {
            this.refreshUI();
            SitefinityWebApp.Controls.BasicEditorDesigner.callBaseMethod(this, 'initialize');
     
            this._toogleGroupSettingsDelegate = Function.createDelegate(this, function ()
            { dialogBase.resizeToContent(); });
     
            this._btnClearAllDelegate = Function.createDelegate(this, this._ClearAllTextfields);
            $addHandler(this._btnClearAll, "click", this._btnClearAllDelegate);
        },
     
        get_htmlEditor: function () {
            return this._htmlEditor;
        },
        set_htmlEditor: function (value) {
            this._htmlEditor = value;
        },
     
        /* ----------------------------- public methods ----------------------------- */
        refreshUI: function () {
            var p = this.get_propertyEditor();
            jQuery(p.get_advancedModeButton()).hide();
     
            this._refreshMode = true;
     
            dialogBase.resizeToContent();
            var html = this.get_propertyEditor().get_control().Html;
            if (html) {
                this._htmlEditor.set_value(html);
            }
        },
     
        _ClearAllTextfields: function () {
            var html = this.get_propertyEditor().get_control().Html;
            if (html) {
                     // empty every cell.
                this._htmlEditor.set_value(html.replace('>.</td>', '> </td>'));
            }
        },
     
        // get the reference to the button that opens page selector
        get_btnClearAll: function () { return this._btnClearAll; },
     
        // sets the reference to the button that opens page selector
        set_btnClearAll: function (value) { this._btnClearAll = value; },
     
        // forces the designer to apply the changes on UI to the cotnrol Data
        applyChanges: function () {
            this.get_propertyEditor().get_control().Html = this._htmlEditor.get_value();
        }
    }
     
    SitefinityWebApp.Controls.BasicEditorDesigner.registerClass('SitefinityWebApp.Controls.BasicEditorDesigner', Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase);
    if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

    My lack of JS experience is restricting me a bit. Just an example will do.

    Many thanks,
    Andrei
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jun 2011
    Link to this post
    Hi Andrei,

    Please use jQuery to loop through table cells

    http://stackoverflow.com/questions/376081/how-to-get-a-table-cell-value-using-jquery

    I updated your support request as well.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    29 Jun 2011
    Link to this post
    Ivan,

    Just in case someone needs to know how to do it through RegEx here is the code that worked in the end. 
    _ClearAllTextfields: function () {
        var html = this.get_propertyEditor().get_control().Html;
        if (html) {
            var pattern = ">.+?<\/td>";
            var re = new RegExp(pattern, "gim");
     
            while ((matches = re.exec(html)) != null)
            {
                for (i = 0; i < matches.length; i++) {
                    html = html.replace(matches[i], '> </td>');
                }
            }
            this._htmlEditor.set_value(html);
        }
    },

    jQuery did not work, it was unable to find the table and it also relies on a table id as well which can't always be guaranteed. 

    Cheers,
    Andrei
5 posts, 0 answered