+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Having a profile field be required on registration widget?

Having a profile field be required on registration widget?

2 posts, 0 answered
  1. Ryan
    Ryan avatar
    57 posts
    Registered:
    07 May 2013
    28 Oct 2013
    Link to this post
    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.
  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    29 Oct 2013
    Link to this post
    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
2 posts, 0 answered