我有這個需要的 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 函數。
如何停止傳播下一個內聯函數
慕的地6264312
2021-11-25 19:05:39
