Mr.Bobo Haha
Mr.Bobo Haha

Reputation: 141

Kendo numeric textbox: how to persist default value even when it was deleted?

I have Kendo numeric textbox.. I just want to know how to show default value when the user deleted the value and click outside the numeric textbox the textbox displays null, how can I make to show again the default value when it was deleted and click to other fields.

Here's my code:

<input id="txtWageFrom" name="txtWageFrom" type="number" class="dropnumeric" value="30" min="10" max="100" />

$("#txtWageFrom").kendoNumericTextBox({
    format: "c",
    decimals: 3,
    value:30,
    change: function () {
         var value = this.value();
         // alert(value); //value is the selected date in the numerictextbox
         if (value == null) {
             alert(value);
         }
    }
});

I tried declaring again the input value on change event but it's not working...

Upvotes: 3

Views: 8696

Answers (2)

Mr.Bobo Haha
Mr.Bobo Haha

Reputation: 141

ahaha tnx for the help but i resolved the problem by doing this

$("#txtWageFrom").kendoNumericTextBox({
    format: "c",
    decimals: 3,
    value: 30,
    change: function () {
        var value = this.value();

        if (value == null) {
            setFromValue();
       }
    }
});
var numerictextbox = $("#txtWageFrom").data("kendoNumericTextBox");
var setValue = function () {
    numerictextbox.value(30);
    alert('sadasdasdwe');
};

Upvotes: 0

user3559349
user3559349

Reputation:

You could handle the blur event

$("#txtWageFrom").blur(function() {
  var kn = $(this).data("kendoNumericTextBox");
  if (kn.value() === null) {
    kn.value(0.0); // set default
  }
});

Upvotes: 3

Related Questions