Page 1 of 1

date picker value via JS

Posted: Thu Jun 06, 2013 1:32 pm
by doubletake

How do I reference the value of the datepicker in JS by using the name of the datepicker component?

The dates are required fields in my validation. I have multiple dates in the same page (e.g. startDate, endDate, etc.), so it cannot be based on a generic selector.

Thanks,
Don


date picker value via JS

Posted: Thu Jun 06, 2013 3:26 pm
by Kateryna Grynko

Hi,

I'll take a look.


date picker value via JS

Posted: Thu Jun 06, 2013 3:45 pm
by Kateryna Grynko

Try the following code:
codeAppery("mobiledatepicker_2").getAttr("defaultDateValue")/code


date picker value via JS

Posted: Thu Jun 06, 2013 4:17 pm
by doubletake

Sorry. I didn't asked the right question. My bad :(

Jquery.Validity uses the component id/name selector to check required

$('#myinput').require('this field is required');
$("[name='myinput']").require('this field is required');

this works fine in Appery.io.

in the case of the date picker, it looks like it uses a text input component to store the selected date. It looks like this input doesn't have an name or an id to use. i.e. it doesn't use the name of the mobiledatepicker.

I'm sure I can write something custom for dates using the getAttr, like you suggest here. However, I was hoping not to have to. Lazy :(

Any ideas?


date picker value via JS

Posted: Thu Jun 06, 2013 4:58 pm
by Kateryna Grynko

Appery.io applications are little different from usual web pages.
It's all about the need to automatically generate these web pages. It has a certain effect on the page components use case. The standard Datepicker was modified for the Builder.


date picker value via JS

Posted: Thu Jun 06, 2013 11:26 pm
by doubletake

I got it working by setting the id property of the input child of the datePicker, then using that id for the validation.

I do this in my page load setupValidation() function:

$("[name='startDate']").find('input').attr('id','inputStartDate');

then on submit of of the form, this now works to validate.
$("#inputStartDate").require('required');

Never give up :)


date picker value via JS

Posted: Sun Aug 04, 2013 11:15 am
by Ole Henrik Oftedal

Hi Don!

Thank you so much for not giving up. I have struggled with this over time and my solution worked, but your solution is much much better!

Now it is easy to both set the date and get the selected date from the component.

best regards

Ole H. Oftedal
Timeflex Systemer AS
http://www.timeflex.com
http://www.timeflex.no