gpt4 book ai didi

javascript - IE-9 将占位符的值作为值

转载 作者:行者123 更新时间:2023-12-02 16:58:31 26 4
gpt4 key购买 nike

我的 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 的值时,它向我显示占位符的值。即:

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>

关于javascript - IE-9 将占位符的值作为值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25974079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com