admin管理员组文章数量:1391934
I used Datepicker plugin for getting Calendar in HTML. But my boss ordered me not to t use any jquery plugins for date picker. He is saying that I must use native code only for date picker. It should work without Javascript also.
Is it possible to create native calendar in html ?
I know html5 supports native date picker; but that is not supported by all browsers.
Can i get native date picker as following style..?
I used Datepicker plugin for getting Calendar in HTML. But my boss ordered me not to t use any jquery plugins for date picker. He is saying that I must use native code only for date picker. It should work without Javascript also.
Is it possible to create native calendar in html ?
I know html5 supports native date picker; but that is not supported by all browsers.
Can i get native date picker as following style..?
Share Improve this question edited Aug 4, 2014 at 18:00 mani asked Jul 30, 2014 at 9:59 manimani 1,0447 gold badges27 silver badges49 bronze badges 1- 3 A native non-HTML5 date picker without using Javascript? Sure. It's called a textbox. – Robby Cornelissen Commented Jul 30, 2014 at 10:06
4 Answers
Reset to default 2"Native" and "without JavaScript" is where this idea will not work on older browsers. You could always create an HTML5 datepicker, and non-supportive browsers will fallback to a plain textbox. You could instruct the user to enter a date in MM/DD/YYYY format, and have this format applied by the datepicker, or by hand if the datepicker is unavailable.
This page offers some advice on the HTML5 datepicker: http://html5tutorial.info/html5-date.php
Edit: Alternatively, you could just create three dropdown menus and have the user select the month, day, and year. (Of course without JS in this case, you couldn't have the number of days in a month change with the user's choice, but you could always validate their input on the server.)
You could instruct the user to enter a date in MM/DD/YYYY format, spryno724
This, a simple html5 placeholder
(you can also style css placeholder
) would suffice.
<input type='text' placeholder='dd/mm/yyyy' name='form[datetime]' id='datetime' />
why not make the jquery datepicker a fallback?
pseudocode:
if (! input.supports('date'))
$(input).datepicker();
this way, you get a datepicker if your browser does not support the native one. That is exactly what jQuery's original 'unobtrusive' idea was.
Look at this simple Code. You need to add 2 js files and 1 css file from net.. Don't worry,It is simple
Here it is
<!DOCTYPE html>
<html>
<head>
<title>Date</title>
<script type="text/javascript" src="https://code.jquery./jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare./ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare./ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
</head>
<body>
<input type="text" id="dob" name="date" placeholder="MM/DD/YYYY"/>
<script>
$(document).ready(function(){
var date_input=$('input[name="date"]');
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
date_input.datepicker({
format: 'dd/mm/yyyy',
container: container,
todayHighlight: true,
autoclose: true,
})
})
</script>
</body>
</html>
本文标签: javascriptNative Date Picker in HtmlStack Overflow
版权声明:本文标题:javascript - Native Date Picker in Html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744714562a2621324.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论