Unobtrusive Validation and Numeric Textbox

3 posts, 1 answers
  1. Scott
    Scott avatar
    5 posts
    Member since:
    Jan 2013

    Posted 10 Jun 2013 Link to this post

    Hi, I am new to the Kendo UI controls and am evaluating them for potential use in a new project. I am having difficulty getting unobtrusive validation to work for a numeric text box. On the same view, I am able to get unobtrusive validation to work for a Kendo date picker. I am at a loss to understand what I am missing from my MVC4 project. 

    I have attached the source for my view, my model, my controller and the html output. I have also attached a screen grab of the unobtrusive validation working for the date picker and not the numeric text box.

    Any help would be appreciated. Thanks!
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 12 Jun 2013 Link to this post

    Hello,

    The most likely reason for the problem is that by default jquery.validate ignores hidden inputs. The problem can be avoided by overriding the validator default settings. Please check if adding the code in the snippet below after the validation scripts resolves the problem:

    $.validator.setDefaults({ ignore: '' });
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Scott
    Scott avatar
    5 posts
    Member since:
    Jan 2013

    Posted 12 Jun 2013 Link to this post

    Thanks Daniel. Your suggestion did the trick. I did however have to make sure that the call to setDefaults was done outside of the $(document).ready function in order to see the unobtrusive validation working as expected.  

    Thanks again. Here also is a link on stack overflow that talks about this issue.

    http://stackoverflow.com/questions/8466643/jquery-validate-enable-validation-for-hidden-fields
Back to Top