Jquery滑落不正常

时间:2017-04-11 16:30:11

标签: php jquery html

我已经使用jquery来验证form.i使用了slideDown()。但是错误消息无法正常工作。但是当我使用alert时它正常工作,因为我想要.i将表单操作重定向到registerphp.php page.it包括注册码。

html代码,

(from a in listA
join b in listB on a.Name equals b.Name
group new { a, b } by new { a.Name, b.DataToPick } into gr
select new
{
    Name = gr.Key.Name,
    ListA = gr.Select(x=>x.a).Take(gr.Key.DataToPick)
}
).SelectMany(x => x.ListA).ToList();

下面的Jquery代码

    <form action="registerphp.php" method="post" id="regfrm" name="regfrm">
        <div class="form-group">
            <label for="pwd">Title</label>
            <input type="text" class="form-control" id="title" name="title">
        </div>
        <div class="form-group">
            <label>Name</label>
            <input type="text"  class="form-control" id="name" name="name">
        </div>
        <div class="form-group">
            <label >User Name</label>
            <input type="text" class="form-control" id="uname" name="uname" >
        </div>                                      
        <div class="form-group">
            <label for="pwds">Passowrd</label>
            <input type="password" class="form-control" id="pwds" name="pwds">
        </div>
        <div class="form-group">
            <label>Confirm Password:</label>
            <input type="password" class="form-control" id="pwds2" name="pwds2">
        </div>
        <div class="form-group">
            <label >Email</label>
            <input type="email" class="form-control" id="email" name="email">
        </div>
        <div class="form-group">
            <label>Phone</label>
            <input type="text" class="form-control" id="phone" name="phone">
        </div>
        <div class="form-group">
            <label>Birth date</label>
            <input type="date" class="form-control" id="bdate" name="bdate">
        </div>
        <div class="form-group">
            <label>University</label>
            <input type="text" class="form-control" id="uni" name="uni">
        </div>
        <div class="form-group">
            <label>GPA</label>
            <input type="number" class="form-control" id="gpa" name="gpa" step=".01">
        </div>
        <div class="form-group">
            <label>Address</label>
            <input type="text" class="form-control" id="add" name="add">
        </div>
        <input type="submit" class="btn btn-info btn-block btn-md" value="Submit" name="buttonregister" id="buttonregister"></input>
    </form>

的CSS,

<script type="text/javascript">

$(document).ready(function () {
    $('#buttonregister').click(function () {
        var title=$('#title').val();
        var name=$('#name').val();
        var phone=$('#phone').val();


        if(title=="")
        {
            $('#dis').slideDown().html("<span>Please type Title</span>");
            alert('no');
            return false;
        }
        if(name=="")
        {
            $('#dis').slideDown().html("<span>Please type Name</span>");
            alert('no2');
            return false;
        }
        if(!$.isNumeric(phone))
        {
            $('#dis').slideDown().html("<span>Please type Name</span>");
            alert('no3');
            return false;
        }
    });
});

帮我解决这个问题

0 个答案:

没有答案