Validation message not shown on button click

5 posts, 0 answers
  1. Sushant
    Sushant avatar
    5 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2012 Link to this post

    Hello,

    I have added required field validation on textbox. The validation works on blur event and displays a warning message, but when i click on a Save button the warning is not displayed. I am calling validator.validate() method on button click. Below is the code.

    var validator = $(divOrgUNitDetailView).kendoValidator({
                rules: {
                    required: function (input) {
                        if (input.is(txtOrgName))
                            return input.val() != "";
                        return true;
                    }
                },
                errorTemplate: '<span class="field-validation-error"> ${message}</span>'
            }).data("kendoValidator");

    and on button click i am calling, 
    if(validator.validate()){}

    Thanks,
    Sushant
  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 20 Jul 2012 Link to this post

    Hi Sushant,

    Unfortunately, the provided information is not sufficient in order to track the cause of such behavior. Thus, we will appreciated a small test page in which this issue can be observed locally. Also you may check this online demo where similar scenario is demonstrated.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Sushant
    Sushant avatar
    5 posts
    Member since:
    Jun 2012

    Posted 23 Jul 2012 Link to this post

    got the issue, i had not included "name" attribute in HTML markup for textbox, so kendo was not able to map the validation message with control.

    Incorrect markup
    <input id="txtOrgName" class="k-textbox" style="width: 50%" data-bind="value: selectedOrgUnit.Name, events: { change: change }, enabled: isFormEnabled" required validationMessage="Please enter Organization Name" />

    Correct markup
    <input id="txtOrgName" name="txtOrgName" class="k-textbox" style="width: 50%" data-bind="value: selectedOrgUnit.Name, events: { change: change }, enabled: isFormEnabled" required validationMessage="Please enter Organization Name" />

    Looks like the "name" attribute is mandatory. Can you please include that in documentation?
  5. Sherly
    Sherly avatar
    4 posts
    Member since:
    Jul 2012

    Posted 01 Aug 2013 Link to this post

    Hi,

    I have a custom validator I'm using to validate some fields. It works fine on blur and I can see the validation messages, but I want to call it just before i call the ajax method which saves the data (on click of a button).

    I have this bit of code:

            var rval = $("#MyDiv").kendoValidator().data("kendoValidator");
            rval.validate();

    When I do this it is calling the validate method and it is checking the values (and returning false), but the the validation messages are not shown.

    Could you help fix this issue. I have the name attribute specified in my controls so that is not it.

    Thanks!

    SJ
  6. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 02 Aug 2013 Link to this post

    Hello Sherly,

    I'm afraid that it is not obvious what may be the cause for the described behavior, therefore, please provide a test page in which the issue can be recreated.

    Regards,
    Rosen
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready