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

Validation message not shown on button click

4 Answers 1552 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Sushant
Top achievements
Rank 1
Sushant asked on 19 Jul 2012, 09:16 PM
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

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 Jul 2012, 02:10 PM
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!
1
Sushant
Top achievements
Rank 1
answered on 23 Jul 2012, 04:52 PM
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?
0
Sherly
Top achievements
Rank 1
answered on 01 Aug 2013, 12:50 PM
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
0
Rosen
Telerik team
answered on 02 Aug 2013, 06:56 AM
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!
Tags
Validation
Asked by
Sushant
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Sushant
Top achievements
Rank 1
Sherly
Top achievements
Rank 1
Share this question
or