Regular expressions for form builder text box
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
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
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();
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
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);
,