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

Display successful client side validation?

1 Answer 87 Views
Input
This is a migrated thread and some comments may be shown as answers.
DH
Top achievements
Rank 1
DH asked on 29 Nov 2014, 10:25 PM
Its relatively easy to do client-side validation and display an error message, however it seems difficult to show a success message in a simple / easy way.

It seems like the only way to do this is to write a bit of javascript that hooks into the ClientEvents-OnBlur(), then have this function check validity again, and apply the proper class, correct? 

Does anyone have a working example?

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 03 Dec 2014, 03:04 PM
Hello,

In order to indicate successful validation you can use JavaScript. Check out the following code-snippets that illustrate an approach you could use. It includes a CustomValidator control:

Markup:

<telerik:RadTextBox runat="server" ID="TextBox1" />
<asp:CustomValidator ControlToValidate="TextBox1" runat="server" ValidateEmptyText="true" EnableClientScript="true" ClientValidationFunction="clientValidate" />

JavaScript:

function clientValidate(sender, args) {
    if (args.Value.indexOf("test") != -1) {
        args.IsValid = true;
        document.getElementById("validStatus").innerHTML = "Valid";
        document.getElementById("validStatus").style.color = "#00dd00";
 
    } else {
        args.IsValid = false;
        document.getElementById("validStatus").innerHTML = "Not Valid";
        document.getElementById("validStatus").style.color = "#ff0000";
    }
 
}


Regards,
Viktor Tachev
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
Input
Asked by
DH
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or