使用javascript驗證和一些jquery在DOM中顯示變量錯誤消息,並突出顯示錶單標籤和字段。突出顯示多個輸入ID的JavaScript驗證
對於這個特定的錯誤信息,我需要突出顯示2個字段(email1和email2)。 不確定如何將它添加到我的當前設置爲以下警報:
customAlert ("email2",bnadd_msg_022);
簡單的問題,如何我添加EMAIL1混進去?
編輯:
這裏是我的jQuery函數:
function customAlert(inputID,msg){
$("li").removeClass("alertRed");
$("input").removeClass("CO_form_alert");
$("select").removeClass("CO_form_alert");
var div = $(".errorPopup");
div.css({"display":"block"});
$("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
if (div.length == 0) {
div = $("<div class='errorPopup' onclick='$(this).hide();'></div>");
$("body").prepend(div);
}
div.html(msg);
$("#"+inputID).focus(function(){
$(this).unbind('focus'); // remove this handler
$('.errorPopup').hide(); // hide error popup
});
所以,在這種情況下,和另外一個,我需要強調同時
這將取決於什麼 「customAlert()」 函數的模樣。 – Pointy
如果你可以發佈簡單的HTML和JS,你會得到更好的答案 –
@Pointy @Bobby Borszich - 見上面的編輯。謝謝。 – Jason