My input control is rendered as:
<input class="form-control datepicker" id="elements_3__Value" name="elements[3].Value" type="date" value="" data-val="true" data-val-required="D.O.B is Required." data-val-range="D.O.B can only be between 1/01/2017 and 2/01/2017." data-val-range-min="1/01/2017" data-val-range-max="2/01/2017">.
The scripts that are loaded on the page are: jquery-1.10.2.js, bootstrap.js, bootstrap-datepicker.js,respond.js, jquery.validate.js, jquery.validate.unobtrusive.js
Date range & date selected in textbox are in MM/dd/yyyy fromats.
Now my selected date is "01/12/2017" i.e. 12 jan 2017 but still validation shows me error as:
Please help me to solve this problem.
Thanks in advance.
Related
I am using angular 12 with a form containing a material DatePicker. Here is the relevant part of my component's html.
<mat-form-field>
<input formControlName="dateOfBirth" matInput [matDatepicker]="picker" placeholder="Date Of Birth">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
When I submit my form, I get the following value for dateOfBirth field:
Date Tue Dec 14 2021 00:00:00 GMT+0100 (Central European Standard Time)
Instead of this output, I would like an output of the form e.g. DD-MM-YYYY. Obviously, I could format this value afterwards but I was wondering if this could be done during the submit mechanism. Would you know how to do this ?
I am developing an application for Human resources, in my application I used mat-calendar for dates, some of my users want to type the date directly in mat-calendar without using the click event to choose the year and month and day. I wonder if there is a method to use the two approaches
click one (click on year and month and day)
type the date directly like 23/11/2020 by example
thanks a lot for your help
<!-- date birth -->
<mat-form-field>
<input
matInput
required
name="dateBirth"
ngModel
placeholder="Date Birth"
[matDatepicker]="dateBirthCal"
>
<mat-datepicker-toggle
matSuffix
[for]="dateBirthCal"
></mat-datepicker-toggle>
<mat-datepicker #dateBirthCal></mat-datepicker>
</mat-form-field>
<!-- ************* fin date Birth *************-->
I am working on JQuery Mobile Datebox and there is something i can't fix. If user type some weird input in year area something like 1988123, datebox gets crazy and changes value of date "undefined, undefined NaN, NaN".
I tried the get only year value from Datebox, but day, month or year area doesn't have id field. So I couldn't get any solution. Can anybody help me?
try HTML5 pattern:
<form
onsubmit="alert('Submitted.');return false;">
<input
type="text"
required=""
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"
value=""
name="dates_pattern2"
id="dates_pattern2"
list="dates_pattern2_datalist"
placeholder="Try it out.">
<input
type="submit"
value="ยป">
<datalist
id="dates_pattern2_datalist"></datalist>
</form>
Finally I did find a solution.
As you know, JQuery Mobile Datebox has some data-options. I find an option which is "maxYear".
<input name="tarih1" id="tarih1" type="date" data-role="datebox" data-options='{"mode": "datebox", "maxYear":"3000"}' placeholder="GG.AA.YYYY">
With this solution, user can't choose a year which has more than 4 digit. (You can change 3000 to another 4 digit year. Bu don't forget, if you choose for example 1999, user can't choose greater than 1999)
In the HTML5 date input type, Chrome will not put in a default date. The field is rendered empty. Other browsers will have the date, but Chrome has a default date selector that may be causing some of the issues. Any ideas?
<input type="date" class="input-xlarge" id="date" name="date"
pattern="(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" value="#Model.Date.ToString("MM/dd/yyyy")" required />
HTML5 date value format is yyyy-MM-dd, not MM/dd/yyyy.
I am using the following to set the date of the datebox plugin
<input data-id="ti_datebox" type="date" data-role="datebox" data-options='{"useInline":true, "noSetButton":true}'>
$ti_datebox.trigger('datebox', {'method':'set', 'value': theDateStr, 'date':theDate})
However, I can't set the time with the same code.
<input data-id="ti_datebox" type="date" data-role="datebox" data-options='{"useInline":true, "noSetButton":true, "mode": "timebox"}'>
$ti_datebox.trigger('datebox', {'method':'set', 'value': theDateStr, 'date':theDate});
Ideally, I'd like to set the time based on some string values and not an actual date object.
Is this possible? If not, how can I set the time?
Any help much appreciated.
It's actually easier than you are making it - DateBox has a 'set' method as well, that takes a string as a value (in the same format as it outputs as it happens). There is no need to send it a date object as well - it will handle creating that.
So, you would:
// For 12hr clock
$('datebox element').trigger('datebox', {'method':'set', 'value':'08:00 AM'});
// For 24hr clock
$('datebox element').trigger('datebox', {'method':'set', 'value':'08:00'});
A working example is here:
http://jsfiddle.net/jtsage/AbVqh/1/
fwiw, if you for some reason need more control, all the set method actually does is change the value in the input box, and call the "refresh" method - which re-reads the input.
I think you are looking for this:
$('input[data-id="ti_datebox"]').trigger('datebox', {'method':'set','value':"08:00"});
Let me know if that helps.
Here is the example for the demo site
http://dev.jtsage.com/jQM-DateBox/demos/time/
http://dev.jtsage.com/jQM-DateBox/demos/api/events.html
Time Default
<label for="mydate">Some Time</label>
<input name="mydate" id="mydate" type="date" data-role="datebox"
data-options='{"mode": "timebox"}'>
12 Hour Clock Mode
<label for="mydate">Some Time</label>
<input name="mydate" id="mydate" type="date" data-role="datebox"
data-options='{"mode": "timebox", "timeFormatOverride": 12}'>