EGHDK
EGHDK

Reputation: 18130

How to add a link to a button in Bootstrap?

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?

Upvotes: 0

Views: 1002

Answers (1)

Bass Jobsen
Bass Jobsen

Reputation: 49044

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/">.

Upvotes: 1

Related Questions