Regular expressions for form builder text box

Posted by Community Admin on 03-Aug-2018 16:36

Regular expressions for form builder text box

All Replies

Posted by Community Admin on 23-Aug-2010 00:00

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

Posted by Community Admin on 23-Aug-2010 00:00

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

Posted by Community Admin on 28-Jun-2011 00:00

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

Posted by Community Admin on 29-Jun-2011 00:00

Hi Andrei,

Please use jQuery to loop through table cells

stackoverflow.com/.../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

Posted by Community Admin on 29-Jun-2011 00:00

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

This thread is closed