ValidatorDefinition not firing for custom fields
Hi,
I'm changing the Registration Form widget's template with this one:
01.
%@ Control Language="C#" %>
02.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
03.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
04.
<%@ Register TagPrefix="sfvalidation" Namespace="Telerik.Sitefinity.Web.UI.Validation.Definitions" Assembly="Telerik.Sitefinity"%>
05.
06.
<
fieldset
class
=
"sfregisterFormWrp"
>
07.
<
asp:Panel
ID
=
"formContainer"
runat
=
"server"
DefaultButton
=
"registerButton"
>
08.
<
ol
class
=
"sfregisterFieldsList"
>
09.
<%--First Name Field--%>
10.
<
sf:TextField
ID
=
"firstName"
runat
=
"server"
DataFieldName
=
"FirstName"
DataItemType
=
"Telerik.Sitefinity.Security.Model.SitefinityProfile"
DisplayMode
=
"Write"
Title="<%$ Resources:Labels, FirstName %>" CssClass="sfregisterField sfregisterFirstName" WrapperTag="li">
11.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
/>
12.
</
sf:TextField
>
13.
<%--Last Name Field--%>
14.
<
sf:TextField
ID
=
"lastName"
runat
=
"server"
DataFieldName
=
"LastName"
DataItemType
=
"Telerik.Sitefinity.Security.Model.SitefinityProfile"
DisplayMode
=
"Write"
Title="<%$ Resources:Labels, LastName %>" CssClass="sfregisterField sfregisterLastName" WrapperTag="li">
15.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
/>
16.
</
sf:TextField
>
17.
<%--Phone Number Field--%>
18.
<
sf:TextField
ID
=
"phoneNumer"
runat
=
"server"
DataFieldName
=
"PhoneNumber"
DataItemType
=
"Telerik.Sitefinity.Security.Model.CustomerProfile"
DisplayMode
=
"Write"
Title
=
"Phone number"
CssClass
=
"sfregisterField"
WrapperTag
=
"li"
>
19.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
/>
20.
</
sf:TextField
>
21.
<%--Email Field--%>
22.
<
sf:TextField
ID
=
"email"
runat
=
"server"
DataFieldName
=
"Email"
DisplayMode
=
"Write"
Title="<%$ Resources:Labels, Email %>" CssClass="sfregisterField sfregisterEmail" WrapperTag="li">
23.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
ExpectedFormat
=
"EmailAddress"
/>
24.
</
sf:TextField
>
25.
<%--Username Field--%>
26.
<
sf:MirrorTextField
ID
=
"userName"
runat
=
"server"
DataFieldName
=
"UserName"
MirroredControlId
=
"email"
WrapperTag
=
"li"
/>
27.
<%--Password Field--%>
28.
<
sf:TextField
ID
=
"password"
runat
=
"server"
DisplayMode
=
"Write"
Title="<%$ Resources:Labels, Password %>" IsPasswordMode="true" CssClass="sfregisterField sfregisterPassword" WrapperTag="li">
29.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
/>
30.
</
sf:TextField
>
31.
<%--Re-password Field--%>
32.
<
sf:TextField
ID
=
"reTypePassword"
runat
=
"server"
DisplayMode
=
"Write"
Title="<%$ Resources:UserProfilesResources, ReTypePassword %>" IsPasswordMode="true" CssClass="sfregisterField sfregisterConfirmPassword" WrapperTag="li">
33.
<
ValidatorDefinition
MessageCssClass
=
"sfError"
>
34.
<
ComparingValidatorDefinitions
>
35.
<
sfvalidation:ComparingValidatorDefinition
ControlToCompare
=
"password"
36.
Operator
=
"Equal"
ValidationViolationMessage="<%$ Resources:ErrorMessages, CreateUserWizardDefaultConfirmPasswordCompareErrorMessage %>"/>
37.
</
ComparingValidatorDefinitions
>
38.
</
ValidatorDefinition
>
39.
</
sf:TextField
>
40.
</
ol
>
41.
<
asp:Panel
ID
=
"errorsPanel"
runat
=
"server"
CssClass
=
"sfErrorSummary"
Visible
=
"false"
/>
42.
<
div
class
=
"sfregisterLnkWrp"
>
43.
<
asp:Button
runat
=
"server"
ID
=
"registerButton"
Text="<%$ Resources:UserProfilesResources, Register %>" CssClass="sfregisterSaveLnk"/>
44.
</
div
>
45.
</
asp:Panel
>
46.
<
sf:SitefinityLabel
id
=
"successMessageLabel"
runat
=
"server"
WrapperTagName
=
"div"
CssClass
=
"sfSuccess"
/>
47.
<
asp:Panel
ID
=
"configurationErrorsPanel"
runat
=
"server"
CssClass
=
"sfErrorSummary"
Visible
=
"false"
>
48.
<
div
runat
=
"server"
id
=
"smtpSettingsErrorWrapper"
Visible
=
"false"
>
49.
<
asp:Label
runat
=
"server"
id
=
"smtpConfigurationErrorTitle"
Text="<%$ Resources:ErrorMessages, CannotSendEmails %>"/>
50.
<
asp:Label
runat
=
"server"
id
=
"smtpConfigurationError"
></
asp:Label
>
51.
</
div
>
52.
</
asp:Panel
>
53.
54.
</
fieldset
>
Hello,
Adding a <
ValidatorDefinition
MessageCssClass
=
"sfError"
Required
=
"true"
/> in the template don't fire the field validation
2) I have also a custom field "adress" and a field "country" as ChoiceField wich don't fire the validation either
How can we manage the validation on theses fields ?
Also I am interested on how to manage the email as customer login
The same here. I'm also trying to use custom fields in registration widget and the validation is not firing. Have you guys managed it working?
Nope :(
I'm asking myself what is this system about. One cannot accomplish simple tasks, it is full of bugs, I feel like beta tester. Forums are dead, and even if I open support ticket, they say me either it is by design or the cannot reproduce it. One response takes 48 hours which doesn't help me much. Actually I'm looking forward to finish my current project and never see this system again :/
I experience the same problem especially Robert's. Any luck with this?
Support ticket sent this afternoon. For a simple question like that it shouldn't be, but we have no documentation on this and I should make it work for tomorow... so I don't have alternative ! For what you are stating Robert, it is a known issue... they are delivering to fast and have to much on the fire... to tell the truth I'm really waiting that the other clients full betatest Sitefinity 5 to even think of migrating my system :)
Finally a reply :)
"The
Sitefinity's validation will not be fired for the custom fields in the template
for the registration control. If you want to validate your custom fields, you
should use the standard ASP.NET validation to all controls in the template
(including email, username and password). Using mix of the two different types
of validation controls will not be possible. "
Here is example to validate the email TextField control:
<
sf:TextField
ID
=
"Email"
runat
=
"server"
DataFieldName
=
"Email"
DisplayMode
=
"Write"
Title
=
"Email"
/>
<
asp:RequiredFieldValidator
runat
=
"server"
ControlToValidate
=
"Email"
Text
=
"The user name field is required."
/>
LOL...
I ended up with client side validation using jQuery
Here I am in November of 2015.
Here is this problem, still unsolved in google searches.
Difference?:
<ValidatorDefinition MessageCssClass="sfError" Required=" ExpectedFormat="Custom"/>
Perhaps this is new? What do I do now? How do I code the regex in my custom form?
No need to help, I expect no answer.
This is the reason I stepped out. This is an overpriced and overengineered piece of crap - unfortunately, because it has a lot of potential. Use Wordpress instead.
Hi,
I have just published a KB article describing in details how to validate custom fields in Registration form widget: http://www.sitefinity.com/developer-network/knowledge-base/details/how-to-validate-custom-fields-in-registration-widget
You may refer to the below forum thread where the same has been discussed:
www.sitefinity.com/.../validation-failing-in-a-customized-registration-form-template
You can also check the following blog post where you can find another example regarding field validation:
http://www.sitefinity.com/blogs/kaloyan-savovs-blog/2013/12/03/registration-widget-with-integrated-captcha-spam-protection-in-sitefinity-cms
Regards,
Sabrie Nedzhip
Telerik