验证表单onSubmit不起作用

时间:2014-08-20 12:50:56

标签: javascript php jquery html validation

我使用php动态生成布局,这可以在底部的代码中看到:

我想验证以下字段

    <input type="text" id="bid" name="bid" class="form-control" />

提交表格时。

我尝试过以下方法只是为了表明表单正在通过脚本,但警报没有显示:

<script>
$("form").validate({
    submitHandler: function () {
        alert('successful submit');
    }
});
</script>

但是表单提交并且不显示警告消息。我不确定我做错了什么。我希望有人可以提供帮助

                    while( $row = $results->fetchArray()){ 
            $lotNo = $row['lotNo'];

                <div class="plan-container">
                    <div class="plan stacked">
                        <div class="plan-header">

                            <div class="plan-title">
                                <?php echo $row['artist']; ?>               
                            </div> <!-- /plan-title -->

                            <div class="plan-price">
                                <a href="./<?php echo $row['image']; ?>" class="ui-lightbox">
                                    <img width="250px" height="auto" src="./<?php echo $row['image']; ?>_t.jpg" />
                                </a>
                            </div> <!-- /plan-price -->

                        </div> <!-- /plan-header -->            

                        <div class="plan-features">
                            <ul>
                                <li><strong>Lot: </strong><?php echo $row['lotNo']; ?></li>
                                <li><strong>Title: </strong> <?php echo $row['lotNo']; ?></li>
                                <li><strong>Size: </strong>  <?php echo $row['size']; ?></li>
                                <li><strong>Medium: </strong>  <?php echo $row['medium']; ?></li>
                                <li><strong>Estimate: </strong> £400 - £600</li>
                                <li><strong>Current Bid: </strong>  £<?php echo $row['bid']; ?></li>
                            </ul>
                        </div> <!-- /plan-features -->

                        <form class="form-inline well" role="form" id="form" method="post" action="./script_place_bid.php?auctionNo=<?php echo $auctionNo; ?>&lotNo=<?php echo $lotNo; ?>">
                            <div class="form-group">
                                <div class="input-group" style="width: 115px;">
                                    <span class="input-group-addon">£</span>
                                    <input type="text" id="bid" name="bid" class="form-control" />
                                </div>
                            </div>
                            &nbsp;  &nbsp;
                            <div class="form-group">
                                <button type="submit" class="btn btn-danger">Max Bid</button>   
                            </div>
                        </form>


                    </div> <!-- /plan -->
                </div> <!-- /plan-container -->

0 个答案:

没有答案