Validation Failing in a Customized Registration Form Template
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
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
>
protected
override
bool
ValidateInput()
return
base
.ValidateInput() &&
this
.ReTypeEmailField.IsValid();
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
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
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
no one ever done a unique validation? i am digging the forums with poor results :(