How to restrict user to enter specific amount of data

5 posts, 1 answers
  1. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 16 Mar 2011 Link to this post

    Hi,
    I want to restrict the user to enter maximum of 4 alphabets in subjects field, and i also want to control the display size of the subject field.
    Can u please guide me how to perform these activities. Your quick response will be greatly appreciated.

    Thanks & Regards,
    Sher
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Mar 2011 Link to this post

    Hello Sher,

    You can try accessing the subjectTextBox in the FormCreated event like this.
    C#:
    protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
       {
           TextBox subject = e.Container.FindControl("SubjectTextBox") as TextBox;
           subject.Attributes.Add("onkeypress", "OnKeyPress");//attatching keypress evnet
       }
    Clientside:
    function OnKeyPress()
        {
       //your code here
       }

    Thanks,
    Shinu.
  3. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 17 Mar 2011 Link to this post

    Hi,

    Thanks for the reply, i really appreciate that but it is not working for me, it is throwing an exception, i am posting the snapshot od the excaption as an attachment.

    Thanks and Regards,
    Sher
  4. Answer
    Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 Mar 2011 Link to this post

    Hello Sher,

    As an another solution you can find the Subject RadTextBox in the Advanced Form and set the MaxLength property to "4". That way you are not allowed to enter more than 4 characters in the subject textbox:

    protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
       {
           if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit)||(e.Container.Mode == SchedulerFormMode.AdvancedInsert))
           {
               RadTextBox subject = e.Container.FindControl("Subject") as RadTextBox;
               subject.MaxLength = 4;
           }
       }

    Greetings,
    Veronica Milcheva
    the Telerik team
  5. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 18 Mar 2011 Link to this post

    Thanks very much veronica, it was really helpful,

    Thanks and regards,
    Sher
Back to Top