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

Forums / Bugs & Issues / Validation Failing in a Customized Registration Form Template

Validation Failing in a Customized Registration Form Template

5 posts, 0 answered
  1. Yosief
    Yosief avatar
    27 posts
    Registered:
    20 Mar 2008
    31 Jan 2013
    Link to this post

    Hi All

    I have added some validation to the default registration form template in the following way:

    <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">               

    <validatordefinition  messagecssclass="sfError" required="true" />         

    </sf:TextField>



    For some unknown reason, there is no validation happening for the above field when the form is submitted. The only validation happening is for email, username and password.

    I later added validation group to each of the required fields in the form. Still no validation happening for the rest of the fields e.g. First name,  Last name etc..

     Any idea why this happening??

    Yosief

  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    04 Feb 2013
    Link to this post
    Hello Yosief,

    If you for example have the following custom field and you want to validate it:

    <sf:TextField ID="reTypeEmail" runat="server" DisplayMode="Write" Title="Retype Email" IsPasswordMode="true" CssClass="sfregisterField sfregisterConfirmPassword" WrapperTag="li">
                    
                  <ValidatorDefinition MessageCssClass="sfError">
                      <ComparingValidatorDefinitions>
                          <sfvalidation:ComparingValidatorDefinition ControlToCompare="email"
                              Operator="Equal" ValidationViolationMessage="Please enter the same email"/>
                      </ComparingValidatorDefinitions>
                  </ValidatorDefinition>
                  </sf:TextField>

    The default registration form control doesn't validate custom fields.You should override its ValidateInput() method of the control  to return true when your field is validated. You can see how this is done in the sample:
    protected override bool ValidateInput()
            {
                return base.ValidateInput() && this.ReTypeEmailField.IsValid();
            }

    To do that you should simply inherit from our Registration form and override the above method.

    Greetings,
    Jen Peleva
    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
  3. Mansoor
    Mansoor avatar
    52 posts
    Registered:
    29 Jul 2013
    04 Sep 2013 in reply to Jen Peleva
    Link to this post
    Hi Jen,

    Where can i add this method validateInput() in the  solution. If i want to add validation for custom feilds. where have to write the code.

    Please help us.

    -Mansoor
  4. Nayden
    Nayden avatar
    11 posts
    Registered:
    22 Feb 2013
    10 Feb 2014 in reply to Mansoor
    Link to this post
    Hi Mansoor,
    about the validateInput() method :
    The method is inside the RegistrationForm control.

     Because of that you need to extend this control by creating your own custom MonsoorRegistrationForm : RegistrastionForm and override this method as Zheyna suggested.

    Then you can go and replace the default control in the toolbox to be your instead of the sitefinity one.
    Go to >> Administration >> Settings >> Advanced >> Toolboxes >> Toolboxes >> PageControls >> Sections >> Users >> Tools >> RegistrationWidget and change the value of CLR Type or Virtual Path field.

    From now on every time you place an registration widget to a page or layout it will use your widget implementation and your validate method

    Regards, 
    Nayden Gochev






  5. Roshith S
    Roshith S avatar
    0 posts
    Registered:
    05 Sep 2016
    26 Sep
    Link to this post
    I want to set a field as unique. Sitefinity by default does not have any provisions for doing that.  Eg:Username field. No two users must have same usernames. 
    Can anyone tell how to achieve it efficiently. 
    Thanks in Advance
5 posts, 0 answered