0

以下のエラーメッセージは、強調表示されたフィールドで完全に機能しています。今を除いて、異なる機能を必要とする力。現在、エラーメッセージは赤い境界線でフィールドを強調表示し、フォーカスを合わせると境界線が削除されます。ただし、ユーザーが送信を押すまで赤の強調表示を維持する必要がある権限onclick="return formSubmit()"

.submit関数を使用してみました(バインド解除を削除し、.focus関数からフォーカスを削除しましたが、赤い強調表示は関係なく持続します。

<!--Jquery function to override JS alert with DOM layer alert message-->
function customAlert(inputID,msg){
   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
        $(this).removeClass("CO_form_alert")
               .parent().removeClass("alertRed"); // undo changes
        $('.errorPopup').hide(); // hide error popup
   });

}
4

2 に答える 2

0

わかりません。そうでない場合は教えてください、しかしあなたはただすることはできません:

$('.theform').submit(function() {

  $('input', this).removeClass('CO_form_alert').parent().removeClass('alertRed');
  $('.errorPopup').hide();    

  return false;
});

なぜバインドを解除する必要があるのですか?

于 2011-06-27T20:16:49.360 に答える
0

私は上記の解決策を探すことに非常に狭心でした-removeClassをフォーム送信と結び付けようとしました(これはそれに結び付けられた多くのアクションを必要とし、過度に複雑でした)。

代わりに、エラーチェックの最初にremoveクラスを実行しました。

$("li").removeClass("alertRed");
$("input").removeClass("CO_form_alert");  
$("select").removeClass("CO_form_alert"); 
于 2011-06-29T14:11:13.313 に答える