【发布时间】:2013-04-17 05:09:47
【问题描述】:
当没有文本/空格时,我正在尝试获取弹出块。它在 Firefox、Chrome 和 Safari 中运行良好。
请检查我的 JavaScript 文件中的以下代码:
function submitQuestion(URL,docId,errorMessage)
{
var question = $('textField').value;
if(!question.blank())
{
var submitForm = $("question-form");
submitForm.action = URL+"docId="+docId+"&question="+encodeURIComponent(question);
//alert(submitForm.action);
submitForm.submit();
}
else
{
alert(errorMessage);
return false;
}
}
上述功能在 Firefox、Safari 和 Chrome 中运行良好,因为当文本框中没有任何内容(即空/空白)时,它会转到 else &prompt errorMessage 作为弹出窗口,但在 IE 中,它不会转到 else &errorMessage pop -up 永远不会到来。
请检查以下代码以获取我的 forntend 表单-:
<form method="POST" id="question-form" onsubmit="return submitQuestion('https://localhost/question-post!input.jspa?','ABC12','Enter your question!');">
<span class="fieldwrap">
<input type="text" placeholder="Ask customers about this document" value="" maxlength="255" autocomplete="off" class="questionInputField" id="textField">
</span>
<div class="clear"></div>
<div id="question-submit" class="widget-div clearfix">
<input type="submit" value="Submit question to the portal" class="questionSubmitFormButton">
</div>
</div>
</form>
在 IE 中发生的情况是,当我们没有提供任何内容时,它将占位符作为文本字段的值,即当我们将文本字段保持为空或空白时,它将占位符作为文本字段值 & 而不是弹出-警告,它会进入不应该是这种情况的 if 循环。
【问题讨论】:
-
你在什么活动上这样做?不要在提交事件中提交表单 - 请说明您在何处以及如何调用此代码
标签: javascript internet-explorer popup emptydatatext