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

range validation

2 Answers 102 Views
Validation
This is a migrated thread and some comments may be shown as answers.
JCSCo
Top achievements
Rank 1
JCSCo asked on 19 Sep 2014, 09:45 PM

Hello,

I am trying to validate a year range in a numeric text box in a grid. I am able to validate one end of the range, but not the other. For example, this works:

   validation: { custom:
          function (input) {
                 input.attr("data-custom-msg", "Year out of range");
                 return input.val() >= 1970; 
                }
        }

but when i try this:

   validation: { custom:
           function (input) {
                  input.attr("data-custom-msg", "Year out of range");
                   return input.val() >= 1970 || input.val() <= 2050;
                  }
        }

it will not catch either end of the range. Is there a way to validate a range of numbers?

Thanks

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Sep 2014, 12:46 PM
Hi,

The result of the condition:
input.val() >= 1970 || input.val() <= 2050
will be true for any number. You should use the && operator instead.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
JCSCo
Top achievements
Rank 1
answered on 23 Sep 2014, 01:03 PM
Thanks. Guess I didn't think that one all the way through.
Tags
Validation
Asked by
JCSCo
Top achievements
Rank 1
Answers by
Daniel
Telerik team
JCSCo
Top achievements
Rank 1
Share this question
or