Validation Failing in a Customized Registration Form Templat

Posted by Community Admin on 04-Aug-2018 10:33

Validation Failing in a Customized Registration Form Template

All Replies

Posted by Community Admin on 31-Jan-2013 00:00

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

Posted by Community Admin on 04-Feb-2013 00:00

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

Posted by Community Admin on 04-Sep-2013 00:00

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

Posted by Community Admin on 10-Feb-2014 00:00

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






Posted by Community Admin on 26-Sep-2016 00:00

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

Posted by Community Admin on 17-Dec-2017 00:00

no one ever done a unique validation? i am digging the forums with poor results :(

This thread is closed