-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Datepicker doesn't work with ng-model-options="{ allowInvalid: true }" #4694
Comments
After some thought, I think what I'm really looking is for an option to make the datepicker's validation a bit looser, specifically, to allow leading 0's. The whole reason I was trying to disable validation is because the datepicker errors if the format isn't exactly right, so if the user enters "7/09/2015", it'll error if my format is "M/d/yyyy". Even though the datepicker should still output the desired format, it would be nice if there was an option to allow leading 0's in the input. For now, I've modified the regexs in dateParser to accept leading 0's for days and months. I don't like modifying a library because it means extra effort when you upgrade, but I really don't see any other option since there's no way to extend/modify the date parsing. After looking at the code, I'm starting to see that disabling validation isn't that useful, since the datepicker sets the model value to be a date object, and if it can't parse the date, it still can't output anything. I see that the date parser uses a big object of formats, with a regex for each format. What if we exposed this object, so that external code could override the formats? |
I think this may be a duplicate of #2906. |
We added dateparser support for optional leading zeroes, but it would be nice to add support for all ngModelOptions config |
Closing in favor of #4837 |
I'm still having issues with this. I'm on version 1.1.2 angular-bootstrap, and have a uib-datepicker-popup="MM-dd-yyyy" with ng-model-options="{allowInvalid:true}". So my form requires users to enter dash "-" if they don't know the date. Everything is fine when they enter the dash, datepicker still opens on click if they want to change it to a date, form saves. Now, when form is loaded, ng-model takes the value of "-" dash and doesn't display it in input text box, also when user clicks on datepicker an error pops up with exception: "TypeError: this.activeDate.getFullYear is not a function at _refreshView" Can you help me out with this issue? seems like on load the datepicker doesn't take "-" dash value. |
I'm trying to get the datepicker's input to set the model value even if the user entered invalid stuff, but it doesn't appear to respect ng-model-options' allowInvalid parameter.
The text was updated successfully, but these errors were encountered: