Conditional errorTemplate

3 posts, 1 answers
  1. James
    James avatar
    26 posts
    Member since:
    Nov 2015

    Posted 03 Feb 2017 Link to this post


    I am looking at doing remote validation using custom rules and I found approach which is exactly what I am looking for, however I would like to show a message using different styling/template when a field is in "checking.." state vs when there is an actual error, 

    Is there any way to specify an error template only for single field or conditionally change the error template based on for what field it is showing the error message, also I am using AngularJS version





  2. Answer
    Tsvetina avatar
    2481 posts

    Posted 07 Feb 2017 Link to this post

    Hello Ketul,

    The errorTemplate cannot be defined on per input basis. You can create a custom rule that matches a single input only and provide a message of your choice for it, as shown in this code snippet.

    If you need to change the styling of the input while it is in the checking state, consider adding a custom CSS class to it when you enter the availability.check function (from the example in the blog post). Using this class, you can overwrite the default error style during the AJAX call only. In the AJAX request complete callback, you can remove this class from the input element, so the normal valid/invalid styles can kick in.

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. James
    James avatar
    26 posts
    Member since:
    Nov 2015

    Posted 08 Feb 2017 in reply to Tsvetina Link to this post

    Thanks I think the CSS trick will do
Back to Top