生活随笔
收集整理的這篇文章主要介紹了
form表单提交之前判断
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.使用onsubmit方法
?
<form?name="Form"?action="t"?method="post"?οnsubmit="return?check();">??<input?class="btn?btn-default"?id="excel_file"?type="file"?name="filename"??accept="xls"/>??<input??id="excel_button"?type="submit"?value="導入Excel"/>??</form>??
???function?check()?{??????alert("check");??????var?excel_file?=?$("#excel_file").val();??????if?(excel_file?==?""?||?excel_file.length?==?0)?{??????????alert("請選擇文件路徑!");??????????return?false;??????}?else?{?????????????return?true;?????????}??}?? 2.使用按鈕事件綁定
?
$("#excel_button").on('click',?function()?{??????????var?excel_file?=?$("#excel_file").val();??????????if?(excel_file?==?""?||?excel_file.length?==?0)?{??????????????alert("請選擇文件路徑!");??????????????return?false;??????????}?else?{??????????????return?true;??????????}??????});?? ?
總結
以上是生活随笔為你收集整理的form表单提交之前判断的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。