[英]IE-9 taking value of placeholder as a value
我有HTML作為:
<input id="SLOCriteriaOtherText" name="SLOCriteriaOtherText" style="width: 100%;" type="text" data-role="autocomplete" placeholder="Enter name for 'other' metric..." class="k-input" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-readonly="false" aria-owns="SLOCriteriaOtherText_listbox" aria-autocomplete="list">
我只是想對空白文本框檢查進行驗證。
上面的文本框的占位符為:
Enter name for 'other' metric...
我已經完成了對空白文本框檢查的驗證:
if ($("#SLOCriteriaOtherText").val() == "") {
alertMessageText += "Please enter Other criteria text. \n";
}
在Chrome上運行正常。
但是在Internet Explorer上不起作用。
當我警告來自Internet Explorer的SLOCriteriaOtherText的值時,它向我顯示了占位符的值。 IE瀏覽器
Enter name for 'other' metric...
這樣,驗證在Internet Explorer上失敗,並在crome上起作用。
請幫我。
如何在Internet Explorer(版本9)上不帶占位符的情況下SLOCriteriaOtherText
值
嘗試使用此jQuery IE占位符庫。 IE很爛的占位符:)
http://www.moreonfew.com/how-to-make-placeholder-work-in-ie/
用法示例-
包括JS-
<!-- Include the jQuery file -->
<script src="jquery.min.js" type="text/javascript"></script>
<!-- Include the jquery.placeholder.js file -->
<script src="jquery.placeholder.js" type="text/javascript"></script>
定義你的DOM
<input type="text" name="emailAddress" placeholder="Enter your email address" />
<textarea name="about" placeholder="Tell us about yourself" />
占有它:)
<!-- Apply the placeholder functionality to elements
using appropriate jquery selectors -->
<script type="text/javascript">
$('input[type=text], textarea').placeholder();
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.