有人提交我的通讯表单时,我需要使用
JavaScript和jQuery验证输入
这是我到目前为止
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ function go() { if($('#name').val() == '') { alert('error: name is required'); } $('form').submit(); } }); </script> </head> <form method="post" action=""> Name *<input type="text" name="name" id="name"/> E-Mail *<input type="text" name="email" id="email"/> <input class="submit" type="submit" value="Submit" name="submit" id="submit" onclick="go();"> </form>