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

RadTextBox SetFocusOnError Validate Issue

2 Answers 67 Views
Input
This is a migrated thread and some comments may be shown as answers.
parlardin
Top achievements
Rank 1
parlardin asked on 08 Jul 2013, 04:21 AM
i use RequiredFieldValidator to validate radtextbox,SetFocusOnError="true"
telerik version:2012Q3

first ,enter " ",validate event fire, display “notnull”
sencond,enter “123” ,radtextbox not set value,validate event not fire

asp.net textbox is ok

code:
<telerik:RadTextBox ID="txtAppId" runat="server" Width="300" AutoPostBack="false">
        </telerik:RadTextBox>
        <%--<asp:TextBox ID="txtAppId" runat="server" Width="300" AutoPostBack="false">
        </asp:TextBox>--%>
        <asp:RequiredFieldValidator ID="TextBoxRequiredFieldValidator" runat="server" Display="Dynamic"
            ControlToValidate="txtAppId" Text="NOT NULL" ErrorMessage="NOT NULL" SetFocusOnError="true">                          
        </asp:RequiredFieldValidator>

2 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 09 Jul 2013, 04:19 PM
Hi parlardin,

I have tested using the latest version Q2 2013 and it seems to work the same for RadTextBox and Asp:TextBox.

Indeed the "   " is threaded as null, since the code of ASP Validator is like follows:
function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}
function RequiredFieldValidatorEvaluateIsValid(val) {
    return (ValidatorTrim(ValidatorGetValue(val.controltovalidate)) != ValidatorTrim(val.initialvalue))
}
This means that string that does not contain characters different than space will considered as null.

Regards,
Vasil
Telerik
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 the blog feed now.
0
parlardin
Top achievements
Rank 1
answered on 12 Jul 2013, 01:01 AM
version Q2 2013 work fine ,thanks
Tags
Input
Asked by
parlardin
Top achievements
Rank 1
Answers by
Vasil
Telerik team
parlardin
Top achievements
Rank 1
Share this question
or