2012-03-08 24 views
0

私は別の関数validateFormの中で関数notEmptyを呼び出そうとしています。しかし、私はこの関数のセレクタを渡す必要がありますし、フォームを送信した後。サブミットボタン内の関数を呼び出す

は見てみましょう:

$("#accountemail").blur(notEmpty); 
$("#submit_account").click(validateForm); 

function notEmpty() 
{ 
    if($(this).val() == "") 
    { 
     // Send a warning message 
     warn($(this), "notEmpty"); 
     return false; 
    } 

    else 
    { 
     // Remove a warning message 
     unwarn($(this), "notEmpty"); 
     return true; 
    } 
} 

function validateForm() 
{ 
    // How i can call the function passing the selector and after submit the form? 
} 
+0

「セレクタ」とは何ですか? –

+0

フォーム – KillCloud

答えて

0

は、あなたのvalidateForm関数に引数を追加します。いつclcikハンドラの引数として関数名を渡すかjQueryは関数内の要素を返します

$("#submit_account").click(validateForm); 

function validateForm() 

{ 

    /* $(this) will be the same as $("#submit_account")*/ 
} 
+0

の要素ID 'element'にはイベントオブジェクトが含まれていて、最初のスニペットの要素は含まれていませんか? –

+0

おっと。車で。更新。お天気@ケビンB – charlietfl

+0

あなたはもっと正確になりますか?私は$( "#accountemail")を試しました。notEmpty();しかしdoens'tは働きます – KillCloud

関連する問題