0

1.Is it possible to make the "clear" button on the datepicker to be available after I picked a date in both my inputs. After I done it, its impossible to clear the date.

<input name="fromDate" id="fromDate" type="date" min="" max="" />
<input name="untilDate" id="untilDate" type="date" min="" max="" data-dependent-validation='{"from": "fromDate", "prop": "required"}' />

If I picked one I dont want it be possible to post without the other one. That's why im using 'data-dependent-validation'. (I notice their wasn't any language suport on the "clear" button. At least not into swedish).

2.Is their any suport to open up a specific month? Got a own made calendar and want the picker to open up in the month that I choosen. And not todays date as default.

3.Will you include a date spinner as an option for the date picker? (good for mobiles).

OT: I notice on my iphone 4s that the "requierd" attribute was ignored on all off my inputs. Is that anything you noticed? Works as it should on my PC and windows 8 phone.

thatsIT
  • 2,085
  • 6
  • 29
  • 43

1 Answers1

0
  1. a) Make clear available: I think you shouldn't set it to required. Instead you could write something like this:

$('#fromDate').on('change', function(){ if(!$.prop(this, 'value'){ $('#untilDate').prop('value', ''); } });

Does this help?

b) clear locale Yeah, I know. I was very lazy here. It would be extreme nice, if you could compare english and swedish locale for me and do a PR with improved and more usable errormessages/locale settings

  1. Yes. There is the "startValue" option. See in action (afarkas.github.io/webshim/demos/demos/cfgs/input-date.html#startValue=2012-12-12&startView=2):

    input type="date" data-date='{"startValue": "2010-12-12"}' /

  2. a) Currently not. My mobile strategy is to leave input widgets native on mobile and only set replaceUI on desktop.

b) required not working on iOS. Which iOS version are you using? I'm not aware, but if it's iOS 5.1.1+, I will look into it.

alexander farkas
  • 13,754
  • 4
  • 40
  • 41
  • Made som changes in the language file! Happy to help you with that! Their might be some places where it might be better to replace the sentence, but hard to not see it in a situation. Anyway, its good as it is. "clear available:" With that JS it removes the value, it's at workaround. But would be better to have opertunity to press "clear". I'll try it out a bid more with requierd and turn validation off/on. – thatsIT Jan 20 '14 at 14:32
  • "relDefaultValue" worked. A situation: When Im choosing a date from my own "fullsize calendar". I want that date/month to be "preloaded" when im opening the "datepicker". So if today's date i 2014-01-20. And I click in my own calendar "2014-05-05". I want may to be preopened when im open up the "datepicker". As it is now it's opens todays month (if I havn't changed min-max prop). Anyway, your "relDefaultValue" is kinda fix for this. I will return about the iphone/iOS. – thatsIT Jan 20 '14 at 14:39
  • I noticed that if you have "data-dependency" on both of your inputs. Then you gets in "locked" mode of "clear" the dates. In that case its impossible, if you dont manually deletes them. – thatsIT Jan 20 '14 at 14:51
  • btw do you have any update function that I need to run after changed the "relDefaultValue" value. Like this: $('#fromDate').data('date', {"relDefaultValue": 31536000000}); $(document).trigger('updatelayout'). I have it as 0 in my view. – thatsIT Jan 20 '14 at 15:23
  • No, you have to go another way and use some internals: I don't feel too good with this. But are two examples: http://jsfiddle.net/trixta/uB6wN/ – alexander farkas Jan 20 '14 at 17:22
  • Seems hard to get it work. Tried this: var widget = $('#fromDate').getShadowElement().data('wsWidgetdate'); widget.options.relDefaultValue = 31536000000;... But it doesn't get updated. Tried to set the value in the textbox and remove it again. Like a 'hack'. But didn't work. But one hacky thing that could work is if I can set the value through the 'datepicker'. And then remove the value from the input. Next time I open the 'datepicker' the prevalue is what it was when I picked it last time (the fake click), or as in my case a manual pick. – thatsIT Jan 21 '14 at 08:57
  • Will soon be better to create a new thread :). If I got a input with type date with requierd. Then if I post it's open up the datepicker (which is good), but its even shows an empty "bubble", as it shows when you missed to set a value to a type text input. This bubble have no text. It get text IF I got an error bubble from another control with an error message in it. Then it takes that error message and sets it to the input type date bubble. – thatsIT Jan 22 '14 at 08:22
  • About the relDefaultValue hack. I already noticed that. I will look into it today and provide a "better hack" for you (It still remains a hack). About this required empty error bubble thing. This sounds as a bug to me. Could you provide a fiddle, so I can check it? – alexander farkas Jan 22 '14 at 10:49
  • I know what wrong with the bubble now, or atleast why. It's when I set the input fields to required = true and the sets it back to required = false (to fast). Check this fiddle: http://jsfiddle.net/Dt2TE/30/ – thatsIT Jan 24 '14 at 09:53
  • This is not really a bug. You are applying some constraints, then you invoke the validation and then you are removing the constraints. Make simply sure, that your constraints are "final" before you invoke the validation ("feedback"). Native implementations work similiar: see http://jsfiddle.net/trixta/hhSPZ/ Firefox shows an empty error bubble and Chrome does focus the invalid without showing but also not submitting the form. I try to work on your relDefault issue though! – alexander farkas Jan 24 '14 at 13:12
  • Yes I noticed that it wasn't any bug, when I found the problem. Changed my location where I change the required back to false. Then it worked. Yes relDefault issue is more a user friendly thing if it could work. Thanks. – thatsIT Jan 24 '14 at 13:24
  • Ok, just worked on this, pushed to gh-pages and updated my fiddle: http://jsfiddle.net/trixta/uB6wN/. Note you need the newest version and make sure to clear your cache github pages are kind of bad in caching. – alexander farkas Jan 24 '14 at 20:23