How to achive validation while typing

2 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Apr 2009 Link to this post

    Hi,

    I want to use RadTextbox to achieve the following solution:
    http://www.pp-p.net (Type OK into the textbox)

    My Problem(s) - I can't find an event for KeyUp - I found this post:
    http://www.telerik.com/community/forums/aspnet-ajax/input/showing-error-style-programmatically.aspx
    But when I hover the control or type focus it - the error display disappears.
    I guess there are some styles :focus or other like this -- BUT it is hard to figure this out - and you (I'm sure) know which styles are involved.

    I further guess there is a script which changes the class .riError to riFocus or some kind of .riHover - can this script be disabled?

    Or is the solution so much effort that it is better to do it "my way" by using a hidden RadInput (to get the styles) and use a default input?

    Regards

    Manfred
  2. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 28 Apr 2009 Link to this post

    Hi there,

    I managed it.
    It just was a bit confusing where and when styles get changed.
    Finally I managed to solve the problem.
    What I got is a RadTextBox which validates while typing.
    I solved it within a WebUserControl. All properties of the RadInput used are (can be) inherited and passed to the contained control.
    So skinning and other features are still available. :)

    The sample at http://www.pp-p.net/Default.aspx shows two of those controls.
    The definition is simple:
    <uc1:WSTextBox WSMethod="CheckVal2" runat="server" /><br /> 
    <br /> 
    <uc1:WSTextBox SupressSubmitIfInvalid="true" WSMethod="CheckVal3" runat="server" /><br /> 
     
    Notice the SupressSubmitIfInvalid - this parameter decides if the "optical validation" works as "normal validation" which means that submits are suppressed while the control is in invalid state.
    Validation is done with a webmethod - which returns "-1" error - "0" empty and "1" OK.
    The User of the control provides the method and tells the control the name of it via WSMethod="xxx".

    In the sample the two methods look like this (just a stupid example):
    [WebMethod]  
    public static string CheckVal2(string strIn) {  
        if (string.IsNullOrEmpty(strIn)) {  
            return ("0");  
        }  
        if (strIn.Length < 3) {  
            return ("-1");  
        }  
        if (strIn.StartsWith("X")) {  
            return ("1");  
        }  
        return ("-1");  
    }  
    [WebMethod]  
    public static string CheckVal3(string strIn) {  
        if (string.IsNullOrEmpty(strIn)) {  
            return ("0");  
        }  
        if (strIn.Length < 2) {  
            return ("-1");  
        }  
        if (strIn.StartsWith("Y")) {  
            return ("1");  
        }  
        return ("-1");  
    If someone is interested (just reply here) I can post a Code Library project about this usercontrol.

    Regards and sorry for the "unneeded help thread" here

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