在成功提交表格后重定向到Google

时间:2016-03-11 08:00:06

标签: javascript html forms

我创建了一个包含姓名,电子邮件,电话字段的表单。

<div class="col-md-4 col-md-offset-4 my">
 <form  role="form">
      <div class="form-group">
        <label for="contact_name">Name</label>
        <input class="form-control" id="contact_name" name="contact_name" required="true" type="text"/>
      </div>
      <div class="form-group">
        <label for="email_from">Email address</label>
        <input class="form-control" id="email_from" name="email_from" type="email"/>
      </div>
      <div class="form-group">
        <label for="phone">Phone No</label>
        <input class="form-control" id="pnone" name="phone" type="text"/>
      </div>
      <button class="btn btn-primary center-block" style="width: 35%;" type="submit">Submit</button>
    </form>
  </div

我想要动作和提交事件。 操作是在成功提交后提交表单和提交重定向的位置。 成功提交后,我想重定向到Google。

2 个答案:

答案 0 :(得分:0)

   ....   
   document.formNameGoesHere.submit();
   window.location = "http://www.google.com";
});

答案 1 :(得分:0)

试试这个

$(document).ready(function(){
    $(".btn").click(function(){
        $(this).closest('form').submit();
        window.location="www.google.com";
    })
})
相关问题