Validation for custom attributes(email validation)

7 posts, 0 answers
  1. Harikrishnan
    Harikrishnan avatar
    21 posts
    Member since:
    Jul 2012

    Posted 24 Aug 2012 Link to this post

    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
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 28 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Harikrishnan
    Harikrishnan avatar
    21 posts
    Member since:
    Jul 2012

    Posted 30 Aug 2012 Link to this post

    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
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 04 Sep 2012 Link to this post

    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.
  6. Harikrishnan
    Harikrishnan avatar
    21 posts
    Member since:
    Jul 2012

    Posted 04 Sep 2012 Link to this post

    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
  7. Wei
    Wei avatar
    2 posts
    Member since:
    Jan 2014

    Posted 11 Dec 2014 in reply to Ivana Link to this post

    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?   
  8. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 16 Dec 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017