javascript - Kendo Validator Displays Wrong Default Message for ComboBox -


the messages within input elements populated correctly data annotations, kendovalidator seems creating different.

  • q: why happening?
  • q: how fix it? - open updating through javascript

to keep simple, lets @ 1 of drop-downs...

html:
notice how data-val-required contains actual correct message?

<span class="k-widget k-combobox k-header" style="width: 100%;">     <span tabindex="-1" unselectable="on" class="k-dropdown-wrap k-state-default input-validation-error">         <input name="entity.devicetypeid_input" class="k-input k-valid" type="text" autocomplete="off" role="combobox" aria-expanded="false" placeholder="select device type..." tabindex="0" aria-disabled="false" aria-readonly="false" aria-autocomplete="both" aria-owns="entity_devicetypeid_listbox" aria-busy="false" aria-activedescendant="bec66a14-dad2-4632-84ba-02a9e3b5a10d" style="width: 100%;">         <span tabindex="-1" unselectable="on" class="k-select">             <span unselectable="on" class="k-icon k-i-arrow-s" role="button" tabindex="-1" aria-controls="entity_devicetypeid_listbox">select</span>         </span>     </span>     <input data-val="true" data-val-number="the field devicetypeid must number." data-val-required="device type required." id="entity_devicetypeid" name="entity.devicetypeid" required="required" style="width: 100%; display: none;" type="text" aria-required="true" data-role="combobox" aria-disabled="false" aria-readonly="false" aria-invalid="true" class="k-invalid"> </span> 

data annotation:
can see, message in data-val-required correct...

public class deviceannotations {     [required(errormessage = "device type required.")]     public object devicetypeid { get; set; }      [required(errormessage = "state required.")]     public object stateid { get; set; } } 

javascript:
open updating javascript, rather understand why & wrong messages come from...

var validationroutine = {     validate: function (e) {          var comboboxes = $(".k-combobox");          $.each(comboboxes, function (key, value) {              var $input = $(value).find("input.k-invalid");    //<-- kendo foolishly places k-invalid             var $span = $(this).find("span.k-dropdown-wrap"); //<-- span controls dropdown's appearance.              if ($input.length > 0) { // k-invalid exists...                 $span.addclass("input-validation-error");                 return;             }              $span.removeclass("input-validation-error");         });     } };  $('form').kendovalidator(validationroutine); 

screen shot:
enter image description here

not sure this, happens because have required attribute , showing error message based on name="entity.devicetypeid"

entity devicetypeid required

can please try adding

validationmessage="device type required." 

to input.

i think should work, have used not in asp


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -