亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何停止傳播下一個內聯函數

如何停止傳播下一個內聯函數

慕的地6264312 2021-11-25 19:05:39
我有這個需要的 html 代碼://html code<a href="javascript:void(0);" title="Save" onclick="validate(event, document.thisForm); return submitForm(document.thisForm);"></a><form name="thisForm">    //some stuff without submit button and required inputs</form我的 JS 看起來像這樣:function validate(event, form){    var error = '';    var $inputs = jQuery(form).find(':input[required]');    $inputs.each( function() {        if(jQuery(this).val().length === 0) {            error += 'missing value';            return;        }    });    if (error !== '') {        event.preventDefault();        event.stopPropagation();        event.stopImmediatePropagation();        window.alert(error);        return false;    }    return true;}問題在于,當驗證出現問題時,它不可能停止調用 submitForm 函數。
查看完整描述

1 回答

?
拉風的咖菲貓

TA貢獻1995條經驗 獲得超2個贊

將您的onclick事件處理程序更改為:

return validate(event, document.thisForm) && submitForm(document.thisForm);


查看完整回答
反對 回復 2021-11-25
  • 1 回答
  • 0 關注
  • 189 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號