0
我寫的是與Firefox兼容的代碼通過使用此代碼如何使用與Firefox兼容的JS生成新的輸入類型日期?
<!-- cdn for modernizr, if you haven't included it already -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js"></script>
<!-- polyfiller file to detect and load polyfills -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js"></script>
<script>
webshims.setOptions('waitReady', false);
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');
</script>
<div class="col-sm-6 dailydate" id="daily">
<p class="contact-form-daily">
<label for="typeofservice-dailydate" class="sr-only">daily<span>*</span></label>
<input type="date" aria-required="false" size="30" value="" name="daily-date-#1" id="typeofservice-dailydate" class="form-control" placeholder="daily date">
</p>
</div>
,但我已經添加下面的代碼添加新的輸入類型=「日期」每次用戶點擊按鈕。
<span id="responce"></span>
<button class="col-sm-6 btn btn-primary theme_button margin_0 color1" id="add-
button" onclick="addDate()">Add another Date</button>
<script>
var countBox =2;
var boxName = 0;
function addDate()
{
var boxName=countBox;
document.getElementById('responce').innerHTML+='<div class="col-sm-6"><p class="contact-form-daily"><label for="typeofservice-dailydate-'+boxName+'" class="sr-only">daily<span>*</span></label><input type="date" class="form-control" aria-required="false" size="30" id="typeofservice-dailydate-'+boxName+'" value="" name="daily-date-#'+boxName+'" placeholder="Type another date" /> ';
countBox += 1;
}
</script>
當用戶點擊那個按鈕時,瀏覽器會生成一些與Firefox不兼容的'Date'類型的新框。 我該如何解決這個問題?
webshims.setOptions('waitReady', false);
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');
var countBox =2;
var boxName = 0;
function addDate() {
var boxName=countBox;
document.getElementById('responce').innerHTML+='<div class="col-sm-6"><p class="contact-form-daily"><label for="typeofservice-dailydate-'+boxName+'" class="sr-only">daily<span>*</span></label><input type="date" class="form-control" aria-required="false" size="30" id="typeofservice-dailydate-'+boxName+'" value="" name="daily-date-#'+boxName+'" placeholder="Type another date" /> ';
countBox += 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- cdn for modernizr, if you haven't included it already -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js"></script>
<!-- polyfiller file to detect and load polyfills -->
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js"></script>
<div class="col-sm-6 dailydate" id="daily">
<p class="contact-form-daily">
<label for="typeofservice-dailydate" class="sr-only">daily<span>*</span></label>
<input type="date" aria-required="false" size="30" value="" name="daily-date-#1" id="typeofservice-dailydate" class="form-control" placeholder="daily date">
</p>
</div>
<span id="responce"></span>
<button class="col-sm-6 btn btn-primary theme_button margin_0 color1" id="add-button" onclick="addDate()">Add another Date</button>
http://stackoverflow.com/questions/37308953/date-input-not-working-in-firefox – Gerard
@Gerard對不起我的朋友說,是不是我的問題 我問我怎麼能寫輸入類型=「日期」,當用戶點擊按鈕 你可以嘗試我的代碼在Firefox上,以瞭解我的意思是什麼 –
@傑拉德瀏覽器生成的新框是無併發症iant知道第一個輸入符合 –