Input Date compatible with Internet Explorer?

0

I have a form in Html using bootstrap, in all browsers the input type works: "date" only Internet Explorer does not and I need it to be compatible with that browser, I found a way to do it with Script which is the following:

<script type="text/javascript">
var datefield=document.createElement("input")
datefield.setAttribute("type", "date")
if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
    document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n')
    document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n')
    document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n') 
}
</script>

<script>
if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
jQuery(function($){ //on document.ready
    $('#fecha').datepicker();
    })
}
</script>

<form>
    <b>Fecha:</b>
    <input type="date" id="fecha" name="fecha" size="20" />
    <input type="button" value="Submit" name="B1"></p>
</form>

But in the database I save the date in 0000-00-00 Do you know what is due? (In the other navigators I keep the correct date)

    
asked by R.C. Ana 23.06.2017 в 00:57
source

1 answer

1

Very good. It seems to me that when investigating your input type case, it is not compatible with Internet Explorer 11 and recent versions. As I reviewed the information in w3schools: Input Type Information in English

In my case I recommend trying to put text for now, using the PHP format, although I imagine that you are using the date format in a table in the database, this is the code:

<input type="text" name="nombredelinput" value="<?php date_default_timezone_set('America/Santiago'); echo date('Y-m-d');?>"><br/>

The date_default_timezone_set takes the current calendar (you can change the parenthesis, either ('Europe / Madrid') depending on the country and city) and the echo reveals the date on which we are today. It works for all browsers, remember that the input date only works in other browsers (in case of Html) I hope it has helped you, greetings!

    
answered by 23.06.2017 / 15:02
source