JQGrid Datefmt not behaving as expected -


as part of colmodel in jqgrid, have following:

{name:'reviseddate', width:220, editable: true, datefmt:'yyyy/mm/dd',edittype:'text',editrules:{date:true, required:true},search:true, stype:'text'} 

the datefmt , date:true seem working anticipated, except 1 special case. in edit box if user enters "2012/04/", jqgrid accepts valid date value, though missing day of month. other incorrect variations display error message in top of form, text: please enter valid date value - yyyy-mm-dd.

i have tried changing colmodel use datefmt:'yyyy-mm-dd without success.

is there i'm doing wrong? next step roll custom formatter, seems should unnecessary.

version of jqgrid: 4.3.1

solution: ended testing regex against string in beforesubmit event, leaving editrules{date:true} in place. bulk of date validation done built in datefmt, below regex band-aid bug. more ideal solution date validation in same place, usage of form doesn't merit time put it.

var datepattern = new regexp(/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/g);             var revised = $("#reviseddate").val();             if(!datepattern.test(revised))             {                 return[false, "revised date (yyyy/mm/dd/): please enter valid date value - yyyy/mm/mm"];             }             return [true, "success"]; 

you can examine source code of jqgrid implements editrules: {date: true}. it's lines here , internal function $.jgrid.checkdate here. see has too many restrictions. many formats of date not supported. example standard "en-us" format of date (see 'n/j/y') not supported.

so recommend better use custom validation instead. never use editrules: {date: true}.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -