Tempusdominus datetimepicker and ASP.NET MVC
I try to use https://tempusdominus.github.io/bootstrap-4/ in ASP.NET MVC project.
HTML
<div class="input-group date" data-target-input="nearest">
@Html.TextBoxFor(model => model.TimeEnd,
new { @class = "form-control form-control-sm datetimepicker-input",
@data_toggle = "datetimepicker",
@data_target = "#TimeEnd",
type="text"
})
<div class="input-group-append" data-target="#TimeEnd" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
Where model.TimeEnd
is string in the format dd.MM.yyyy HH:mm
JS
$(document).ready(function () {
$('#TimeEnd').datetimepicker({
locale: 'es',
});
});
When I open page the input
has correct value but it is not visible in the datetimepicker.
UPDATE #1
If I set defaultDate via the same model like defaultDate: '@Model.TimeEnd'
(where it is string in the format dd.MM.yyyy HH:mm) then the Spanish localization is gone and I see English calendar! Wow.
And the following error appears
moment-with-locales.min.js:1 Deprecation warning: value provided is
not in a recognized RFC2822 or ISO format. moment construction falls
back to js Date(), which is not reliable across all browsers and
versions. Non RFC2822/ISO date formats are discouraged and will be
removed in an upcoming major release. Please refer to
http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false,
_l: undefined, _i: 14.08.2018 00:00, _f: null, _strict: false, _locale: [object Object] Error
at Function.createFromInputFallback (http://localhost:62959/Scripts/moment-with-locales.min.js:1:3368)
at wa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:21353)
at va (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22064)
at Sa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22146)
at l (http://localhost:62959/Scripts/moment-with-locales.min.js:1:209)
at k.i.getMoment (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14261)
at k.i.defaultDate (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:19874)
at String. (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14947)
at Function.each (http://localhost:62959/Scripts/jquery-3.3.1.js:360:19)
at k.i.options (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14895)
Any clue how to fix this issue?
asp.net-mvc datetimepicker tempus-dominus-datetimepicker
|
show 1 more comment
I try to use https://tempusdominus.github.io/bootstrap-4/ in ASP.NET MVC project.
HTML
<div class="input-group date" data-target-input="nearest">
@Html.TextBoxFor(model => model.TimeEnd,
new { @class = "form-control form-control-sm datetimepicker-input",
@data_toggle = "datetimepicker",
@data_target = "#TimeEnd",
type="text"
})
<div class="input-group-append" data-target="#TimeEnd" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
Where model.TimeEnd
is string in the format dd.MM.yyyy HH:mm
JS
$(document).ready(function () {
$('#TimeEnd').datetimepicker({
locale: 'es',
});
});
When I open page the input
has correct value but it is not visible in the datetimepicker.
UPDATE #1
If I set defaultDate via the same model like defaultDate: '@Model.TimeEnd'
(where it is string in the format dd.MM.yyyy HH:mm) then the Spanish localization is gone and I see English calendar! Wow.
And the following error appears
moment-with-locales.min.js:1 Deprecation warning: value provided is
not in a recognized RFC2822 or ISO format. moment construction falls
back to js Date(), which is not reliable across all browsers and
versions. Non RFC2822/ISO date formats are discouraged and will be
removed in an upcoming major release. Please refer to
http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false,
_l: undefined, _i: 14.08.2018 00:00, _f: null, _strict: false, _locale: [object Object] Error
at Function.createFromInputFallback (http://localhost:62959/Scripts/moment-with-locales.min.js:1:3368)
at wa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:21353)
at va (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22064)
at Sa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22146)
at l (http://localhost:62959/Scripts/moment-with-locales.min.js:1:209)
at k.i.getMoment (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14261)
at k.i.defaultDate (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:19874)
at String. (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14947)
at Function.each (http://localhost:62959/Scripts/jquery-3.3.1.js:360:19)
at k.i.options (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14895)
Any clue how to fix this issue?
asp.net-mvc datetimepicker tempus-dominus-datetimepicker
Have you tried setting thedefaultDate
option?
– user3559349
Nov 13 '18 at 3:05
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
Shouldn't it bedd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?
– user3559349
Nov 13 '18 at 3:45
@StephenMuecke well... I assume it could be dot as well, right? And even if I useformat: 'DD.MM.YYYY HH:mm',
it does not help.
– Academy of Programmer
Nov 13 '18 at 3:46
1
The defaultDate can acceptmoment
object, try give a shot fordefaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….
– Tetsuya Yamamoto
Nov 13 '18 at 3:55
|
show 1 more comment
I try to use https://tempusdominus.github.io/bootstrap-4/ in ASP.NET MVC project.
HTML
<div class="input-group date" data-target-input="nearest">
@Html.TextBoxFor(model => model.TimeEnd,
new { @class = "form-control form-control-sm datetimepicker-input",
@data_toggle = "datetimepicker",
@data_target = "#TimeEnd",
type="text"
})
<div class="input-group-append" data-target="#TimeEnd" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
Where model.TimeEnd
is string in the format dd.MM.yyyy HH:mm
JS
$(document).ready(function () {
$('#TimeEnd').datetimepicker({
locale: 'es',
});
});
When I open page the input
has correct value but it is not visible in the datetimepicker.
UPDATE #1
If I set defaultDate via the same model like defaultDate: '@Model.TimeEnd'
(where it is string in the format dd.MM.yyyy HH:mm) then the Spanish localization is gone and I see English calendar! Wow.
And the following error appears
moment-with-locales.min.js:1 Deprecation warning: value provided is
not in a recognized RFC2822 or ISO format. moment construction falls
back to js Date(), which is not reliable across all browsers and
versions. Non RFC2822/ISO date formats are discouraged and will be
removed in an upcoming major release. Please refer to
http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false,
_l: undefined, _i: 14.08.2018 00:00, _f: null, _strict: false, _locale: [object Object] Error
at Function.createFromInputFallback (http://localhost:62959/Scripts/moment-with-locales.min.js:1:3368)
at wa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:21353)
at va (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22064)
at Sa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22146)
at l (http://localhost:62959/Scripts/moment-with-locales.min.js:1:209)
at k.i.getMoment (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14261)
at k.i.defaultDate (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:19874)
at String. (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14947)
at Function.each (http://localhost:62959/Scripts/jquery-3.3.1.js:360:19)
at k.i.options (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14895)
Any clue how to fix this issue?
asp.net-mvc datetimepicker tempus-dominus-datetimepicker
I try to use https://tempusdominus.github.io/bootstrap-4/ in ASP.NET MVC project.
HTML
<div class="input-group date" data-target-input="nearest">
@Html.TextBoxFor(model => model.TimeEnd,
new { @class = "form-control form-control-sm datetimepicker-input",
@data_toggle = "datetimepicker",
@data_target = "#TimeEnd",
type="text"
})
<div class="input-group-append" data-target="#TimeEnd" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
Where model.TimeEnd
is string in the format dd.MM.yyyy HH:mm
JS
$(document).ready(function () {
$('#TimeEnd').datetimepicker({
locale: 'es',
});
});
When I open page the input
has correct value but it is not visible in the datetimepicker.
UPDATE #1
If I set defaultDate via the same model like defaultDate: '@Model.TimeEnd'
(where it is string in the format dd.MM.yyyy HH:mm) then the Spanish localization is gone and I see English calendar! Wow.
And the following error appears
moment-with-locales.min.js:1 Deprecation warning: value provided is
not in a recognized RFC2822 or ISO format. moment construction falls
back to js Date(), which is not reliable across all browsers and
versions. Non RFC2822/ISO date formats are discouraged and will be
removed in an upcoming major release. Please refer to
http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false,
_l: undefined, _i: 14.08.2018 00:00, _f: null, _strict: false, _locale: [object Object] Error
at Function.createFromInputFallback (http://localhost:62959/Scripts/moment-with-locales.min.js:1:3368)
at wa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:21353)
at va (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22064)
at Sa (http://localhost:62959/Scripts/moment-with-locales.min.js:1:22146)
at l (http://localhost:62959/Scripts/moment-with-locales.min.js:1:209)
at k.i.getMoment (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14261)
at k.i.defaultDate (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:19874)
at String. (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14947)
at Function.each (http://localhost:62959/Scripts/jquery-3.3.1.js:360:19)
at k.i.options (http://localhost:62959/Scripts/tempusdominus-bootstrap-4.min.js:6:14895)
Any clue how to fix this issue?
asp.net-mvc datetimepicker tempus-dominus-datetimepicker
asp.net-mvc datetimepicker tempus-dominus-datetimepicker
edited Nov 13 '18 at 3:29
Academy of Programmer
asked Nov 13 '18 at 3:01
Academy of ProgrammerAcademy of Programmer
17.5k53230378
17.5k53230378
Have you tried setting thedefaultDate
option?
– user3559349
Nov 13 '18 at 3:05
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
Shouldn't it bedd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?
– user3559349
Nov 13 '18 at 3:45
@StephenMuecke well... I assume it could be dot as well, right? And even if I useformat: 'DD.MM.YYYY HH:mm',
it does not help.
– Academy of Programmer
Nov 13 '18 at 3:46
1
The defaultDate can acceptmoment
object, try give a shot fordefaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….
– Tetsuya Yamamoto
Nov 13 '18 at 3:55
|
show 1 more comment
Have you tried setting thedefaultDate
option?
– user3559349
Nov 13 '18 at 3:05
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
Shouldn't it bedd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?
– user3559349
Nov 13 '18 at 3:45
@StephenMuecke well... I assume it could be dot as well, right? And even if I useformat: 'DD.MM.YYYY HH:mm',
it does not help.
– Academy of Programmer
Nov 13 '18 at 3:46
1
The defaultDate can acceptmoment
object, try give a shot fordefaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….
– Tetsuya Yamamoto
Nov 13 '18 at 3:55
Have you tried setting the
defaultDate
option?– user3559349
Nov 13 '18 at 3:05
Have you tried setting the
defaultDate
option?– user3559349
Nov 13 '18 at 3:05
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
Shouldn't it be
dd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?– user3559349
Nov 13 '18 at 3:45
Shouldn't it be
dd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?– user3559349
Nov 13 '18 at 3:45
@StephenMuecke well... I assume it could be dot as well, right? And even if I use
format: 'DD.MM.YYYY HH:mm',
it does not help.– Academy of Programmer
Nov 13 '18 at 3:46
@StephenMuecke well... I assume it could be dot as well, right? And even if I use
format: 'DD.MM.YYYY HH:mm',
it does not help.– Academy of Programmer
Nov 13 '18 at 3:46
1
1
The defaultDate can accept
moment
object, try give a shot for defaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….– Tetsuya Yamamoto
Nov 13 '18 at 3:55
The defaultDate can accept
moment
object, try give a shot for defaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….– Tetsuya Yamamoto
Nov 13 '18 at 3:55
|
show 1 more comment
1 Answer
1
active
oldest
votes
It seems the probelm was around messing up the input
and wraping div
ids.
HTML
<div class="form-group row">
@Html.Label("Finish", new { @class = "col-sm-2 col-form-label", @for = "TimeStart2" })
<div class="col-sm-10">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input id="TimeEnd" name="TimeEnd" value="@Model.TimeEnd" type="text" class="form-control form-control-sm datetimepicker-input" data-target="#datetimepicker1" />
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
JS
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
locale: 'es'
});
});
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273166%2ftempusdominus-datetimepicker-and-asp-net-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems the probelm was around messing up the input
and wraping div
ids.
HTML
<div class="form-group row">
@Html.Label("Finish", new { @class = "col-sm-2 col-form-label", @for = "TimeStart2" })
<div class="col-sm-10">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input id="TimeEnd" name="TimeEnd" value="@Model.TimeEnd" type="text" class="form-control form-control-sm datetimepicker-input" data-target="#datetimepicker1" />
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
JS
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
locale: 'es'
});
});
add a comment |
It seems the probelm was around messing up the input
and wraping div
ids.
HTML
<div class="form-group row">
@Html.Label("Finish", new { @class = "col-sm-2 col-form-label", @for = "TimeStart2" })
<div class="col-sm-10">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input id="TimeEnd" name="TimeEnd" value="@Model.TimeEnd" type="text" class="form-control form-control-sm datetimepicker-input" data-target="#datetimepicker1" />
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
JS
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
locale: 'es'
});
});
add a comment |
It seems the probelm was around messing up the input
and wraping div
ids.
HTML
<div class="form-group row">
@Html.Label("Finish", new { @class = "col-sm-2 col-form-label", @for = "TimeStart2" })
<div class="col-sm-10">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input id="TimeEnd" name="TimeEnd" value="@Model.TimeEnd" type="text" class="form-control form-control-sm datetimepicker-input" data-target="#datetimepicker1" />
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
JS
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
locale: 'es'
});
});
It seems the probelm was around messing up the input
and wraping div
ids.
HTML
<div class="form-group row">
@Html.Label("Finish", new { @class = "col-sm-2 col-form-label", @for = "TimeStart2" })
<div class="col-sm-10">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input id="TimeEnd" name="TimeEnd" value="@Model.TimeEnd" type="text" class="form-control form-control-sm datetimepicker-input" data-target="#datetimepicker1" />
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
JS
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
locale: 'es'
});
});
answered Nov 14 '18 at 2:09
Academy of ProgrammerAcademy of Programmer
17.5k53230378
17.5k53230378
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273166%2ftempusdominus-datetimepicker-and-asp-net-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried setting the
defaultDate
option?– user3559349
Nov 13 '18 at 3:05
@StephenMuecke Please have a look at my updated question.
– Academy of Programmer
Nov 13 '18 at 3:29
Shouldn't it be
dd/MM/yyyy HH:mm
(forward slash, not dot for the separator)?– user3559349
Nov 13 '18 at 3:45
@StephenMuecke well... I assume it could be dot as well, right? And even if I use
format: 'DD.MM.YYYY HH:mm',
it does not help.– Academy of Programmer
Nov 13 '18 at 3:46
1
The defaultDate can accept
moment
object, try give a shot fordefaultDate: moment('@Model.TimeEnd', moment.ISO_8601)
- also worth to read this: stackoverflow.com/questions/43101278/….– Tetsuya Yamamoto
Nov 13 '18 at 3:55