0

I am using the sign in template, but I'm not sure how to add a link when the submit button is successful. Right now the template blocks non-emails. Which is what I need.

But when the email check passes I want it to go to another web page.

Here is the line:

<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>

I tried wrapping it with a <a> tag and it seemed to work once, but never again, which has me thinking that maybe a button tag shouldn't be wrapped with an a tag?

lukasgeiter
  • 147,337
  • 26
  • 332
  • 270
EGHDK
  • 17,818
  • 45
  • 129
  • 204
  • 1
  • That skips the email check though... =( It will go to the link I put in instead of checking whether or not a valid email was entered. – EGHDK Dec 10 '14 at 14:11
  • Generally a form will submit to a script (PHP, ASP or something else) which will deal with the values passed from the form and then return feedback to the user and redirecting them to a thank you page or whatever as well as storing the submitted data somewhere. Bootstrap doesn't provide this functionality. A button shouldn't be wrapped in an anchor tag. – Billy Moat Dec 10 '14 at 14:36
  • I'm confused. @BillyMoat if you click the temple link in the question then click "Submit" you see a little bubble saying that you have to enter a username. When I wrap the button in the link, it doesn't do that anymore. – EGHDK Dec 10 '14 at 16:05
  • Unless you use JavaScript an `a` element can not submit a form, see: http://stackoverflow.com/questions/8169027/how-can-i-submit-a-post-form-using-the-a-href-tag – Bass Jobsen Dec 10 '14 at 18:55

1 Answers1

1

First of all i do not understand why your can not have an action attribute that sends your data to send your form? AFAIK the HTML5 email validator runs before the form submit event. So you can use the following (jquery) code to redirect the form to any other page:

$('.form-signin').on('submit',function(e){
e.preventDefault(); 
alert('redirect to:' + $(this).data('http://www.test.com/')); 
return false;}
);

Notice that i use $(this).data('http://www.test.com/') with <form class="form-signin" role="form" data-redirect-url="http://www.test.com/">.

Community
  • 1
  • 1
Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224