Having a profile field be required on registration widget?

Posted by Community Admin on 04-Aug-2018 18:51

Having a profile field be required on registration widget?

All Replies

Posted by Community Admin on 28-Oct-2013 00:00

I created additional profile fields, such as PhoneNumber for the default profile type. It is set to be required on the back-end. I added the field to the registration widget template:

<sf:TextField ID="PhoneNumber" runat="server" DataFieldName="PhoneNumber" DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write" Title="Phone Number" CssClass="sfregisterField sfregisterPhone" WrapperTag="li" />


I'm able to save this field to the profile, however, it's not making the field required when a user submits a registration form. I tried adding a ValidatorDefinition, such as:

<sf:TextField ID="PhoneNumber" runat="server" DataFieldName="PhoneNumber" DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write" Title="Phone Number" CssClass="sfregisterField sfregisterPhone" WrapperTag="li">
<ValidatorDefinition MessageCssClass="sfError" Required="true"/>
</
sf:TextField>


and it didn't work. 

How can I make these profile fields required on the registration template? Also, if possible, how can I change the error message for the other fields? By default, they just say "Required Field" instead of what's defined in the error label for that profile field. 

Thanks.

Posted by Community Admin on 29-Oct-2013 00:00

Hello Ryan,

In order to achieve your requirements you can use standard asp.net controls and validator, You could insert this example code in your widget template:

<asp:Label Text="Phone Number" runat="server" CssClass="LabelPhone"/>
<asp:Textbox id="phoneNumber" runat="server" CssClass="TextboxPhone"></asp:Textbox>
 
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
    ControlToValidate="phoneNumber"
    ErrorMessage="Phone number is a required field."
    ForeColor="Red">
</asp:RequiredFieldValidator>

More information and examples you could find on that article.

Regards,
Svetoslav Manchev
Telerik
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

This thread is closed