<p class="sougouContent"> </p> <p class="tag"> 関数 url js php </p> 例: <form action="<?php%20echo%20base_url('heli/add');%20?>" method="GET" onsubmit="add()"> ; input name="call" name="call" type="text" value="<?php echo $this->input->get('call');?>" <td><input type="submit" value="Add"></td> <br> <br> <br> <script type="text/javascript"> ) { <br /> var call= $("#call").attr("value"); <br /> if(call== ""){ <br /> return false <br /> } <br /> & < /script> <br /> <br /> -------------------------------------- - ------------ <br /> 私の質問は、フォームを送信するときに、まず js を使用してフォームが空かどうかを確認し、次にバックグラウンドにジャンプして確認することです。 <br /> <br /> <br />ディスカッションへの返信 (解決策)<br /> <br /> <pre class='brush:php;toolbar:false;'><form action="<?php echo base_url('heli/add'); ?>" method="GET" onsubmit="return add();"> <input name="call" name="call" type="text" value="<?php echo $this->input->get('call');?>" /> <td><input type="submit" value="添加" /></td></form><script type="text/javascript"> function add(){ var call= $("#call").attr("value"); if(call== ""){ alert("NO"); return false; } return true; }</script></pre> <br /> 基本的にはこれで完成です。忘れずに jquery ライブラリを含めてください <br /> それ以外の場合は、値を取得するために document.getElementById('') を使用する必要があります <br /> <br /> <pre class='brush:php;toolbar:false;'><form action="<?php echo base_url('heli/add'); ?>" method="GET" onsubmit="return add();"> <input name="call" name="call" type="text" value="<?php echo $this->input->get('call');?>" /> <td><input type="submit" value="添加" /></td></form><script type="text/javascript"> function add(){ var call= $("#call").attr("value"); if(call== ""){ alert("NO"); return false; } return true; }</script></pre> 基本的には、それを書きました それはアウトです、忘れずに jquery ライブラリを含めてください <br /> それ以外の場合は、値を取得するために document.getElementById('') を使用する必要があります <h2> <p class="sougouAnswer"> ----------------- --------- --------------- <br /> 送信したとき、まだ検証が行われず、バックグラウンドに直接ジャンプしました <br /> <pre class='brush:php;toolbar:false;'><form action="test3.php" method="GET" onsubmit="return add();"> <input name="call" id="call" type="text" value=""/> <td><input type="submit" value="添加" /></td></form> <script type="text/javascript"> function add(){ var call= document.getElementById('call').value; if(call== ""){ alert("NO"); return false; } return true; }</script>好人做到底吧,帮你调试一下。你没有检查而直接提交是因为JS有错误,有可能是因为没有引入jquery的原因。</pre> <p class="sougouAnswer"> <br /> <pre class='brush:php;toolbar:false;'><form action="test3.php" method="GET" onsubmit="return add();"> <input name="call" id="call" type="text" value=""/> <td><input type="submit" value="添加" /></td></form> <script type="text/javascript"> function add(){ var call= document.getElementById('call').value; if(call== ""){ alert("NO"); return false; } return true; }</script>好人做到底吧,帮你调试一下。你没有检查而直接提交是因为JS有错误,有可能是因为没有引入jquery的原因。</pre> <br /> -- ----------- -------------------------------------- --- <br /> エビさん、大変お世話になりました <br /> jquery を導入しました js は問題ありません: <br /> <br /> <input type="button" value="Add" onclick="add();" /> を使用しているためです; 値を取得するため、js と jquery には問題はありませんが、フォームが送信されるとき、js 検証は通過しません<p class="sougouAnswer"> 入力には 2 つの name 属性があり、1 つの ID と 1 つの名前である必要があります!変更して動作するかどうかを確認してください。 <p class="sougouAnswer"></script> </form>