2012-03-31 13 views
0

はcheckformは、フォームで使用されている機能をtrueまたはfalseを返し、このコード機能値の確認方法は?

<input type="button" value="Submit" onclick="checkform(form); someotherfunction();" 

を考えます。

checkform()の値がfalseであるかどうかを確認してから、入力をキャンセルしてsomeotherfunction()を呼び出してもかまいません。

私はそれが、その後someotherfunction()を呼び出すことができるようにcheckform()がtrueの場合、どのように私は確認することができ、それは関係なく、値を返すているため、すべてのコールsomeotherfunction()をdosen't

<input type="button" value="Submit" onclick="return checkform(form); someotherfunction();" 

を試してみましたか?

checkform()の値をsomeothefunction()にチェックしたくない場合は、<input行をチェックすることはできますか?

答えて

1

if:同じメカニズムを使用しますが、checkformでsomeotherfunction()を呼び出すよりも、これは完璧に動作しない場合

onclick="if(checkform(form)){someotherfunction();}" 
+2

また、 'onclick =" checkform(form)&& someotherfunction(); "を実行することもできます。" –

+0

あなたとあなたの想像上の短絡/乱暴 – canon

+2

私はifステートメントを受け取りました! –

0

はこれがあなたに

<script> 
var formExist = true; 

function someotherfunction(){ 
    if(formExist){ 
     // do your stuff... 
    } 
} 
</script> 

<body> 
... 

<input type="button" value="Submit" onclick="formExist = checkform(form); someotherfunction();" /> 

... 
</body> 

を助ける()、 はdefinetely仕事します...