ProgrammedChem ProgrammedChem - 1 year ago 55
jQuery Question

JQuery Validation Date on dynamically created form

I want to validate a form that is dynamically generated. If I enter 123 in the form, it always returns true. Here is the code where I dynamically create the form:

//create dummy form so we can validate
$(".clearfix").append('<form action="#" id="dummyform" method="POST">');
$("#dummyform").append('<input type="text" name="dummyelement" class="date form-control" id="dummyelement"/>');

ignore: [],
required: true,
date: true


I input 123, then call:


this always returns true, for any input unless the input is empty. Can anyone elaborate why the date validation is not occuring?



Apparently, the jQuery Validate plugin thinks "123" is a valid value for the date rule. Conversely, enter "abc" and it's not valid.

In other words, you are doing nothing wrong, and should report this as a bug to the developer on his GitHub page. Include the jsFiddle below inside your bug report.


BTW, you do not need to use class="date" along with date: true... that is a redundant declaration of the rule.