This is a migrated thread and some comments may be shown as answers.

Validation for custom attributes(email validation)

6 Answers 462 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Harikrishnan
Top achievements
Rank 1
Harikrishnan asked on 24 Aug 2012, 03:50 PM
Hi,
I am facing an issue in validation in custom attaributes. See the attached image.
The Textbox shuold enter valid emails only.  And the error  mesage  should be show in the bottom of the textbox.Regular expression is possible in this? 

Its very urgent..pls do the needful

Thanks and regards

6 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 28 Aug 2012, 02:23 PM
Hello Harikrishnan,

Take a look at the following help article showing how to add validators to the controls in the advanced form of RadScheduler: http://www.telerik.com/help/aspnet-ajax/scheduler-customizing-advanced-form-formcreated.html (under the 'Add a new custom validator for the description field' section).

I hope it helps.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Harikrishnan
Top achievements
Rank 1
answered on 30 Aug 2012, 08:53 AM
Hi,

But we have to display the error message in advance form only..please see the attached image

http://www.telerik.com/ClientsFiles/384837_Validation.gif

waiting for ur reply

its very urg
0
Ivana
Telerik team
answered on 04 Sep 2012, 07:35 AM
Hi Harikrishnan,

You need to subscribe to the FormCreated server event, as it is shown in the help article I have mentioned in my previous post, and add the following code in its handler:
protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
{
    if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))
    {
        CustomValidator validatorForAttribute = new CustomValidator();
        RadScheduler scheduler = (RadScheduler)sender;
        validatorForAttribute.ValidationGroup = scheduler.ValidationGroup;
        validatorForAttribute.ControlToValidate = "AttrAttr1";
        validatorForAttribute.ErrorMessage = "Attr1 should be more than 5 characters!";
        validatorForAttribute.ClientValidationFunction = "validationFunction";
        (e.Container.FindControl("AttrAttr1") as RadTextBox).Parent.Controls.Add(validatorForAttribute);
    }
}
The ClientValidationFunction should be as follows:
function validationFunction(source, arguments) {
    if (arguments.Value.length > 5) {
        arguments.IsValid = true;
    } else {
        arguments.IsValid = false;
        //You need to find the ID of the span representing the error message of the custom validator.
        //In this case it is: RadScheduler1_Form_ctl27.
        $telerik.$("#RadScheduler1_Form_ctl27").css("visibility", "visible");
    }
}

I hope this will be helpful.

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Harikrishnan
Top achievements
Rank 1
answered on 04 Sep 2012, 08:09 AM
Thanks for the display........................

Its working fine.......Thanks..


I forgot to add this code

(e.Container.FindControl(

"AttrEmailAddress") as RadTextBox).Parent.Controls.Add(validatorForDescription);

 



Now working fine
0
Wei
Top achievements
Rank 1
answered on 11 Dec 2014, 09:48 PM
Ok, I'm trying to do the same thing.  Validate a custom attribute that I've added to the Advanced from.  I followed the example from the link that you shared above but I'm having an issue where the error message is not appearing when the validation fails. Can you please assist with this?   
0
Nencho
Telerik team
answered on 16 Dec 2014, 12:07 PM
Hello Wei,

In order to investigate the issue that you are currently facing, I would suggest you to submit a support ticket and attach the implementation that you use at your end. Thus we would be able to inspect it locally and troubleshoot the problem for you.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Harikrishnan
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Harikrishnan
Top achievements
Rank 1
Wei
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or