<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
This is the sample code from bootstrap, how can I add a link in this button while keep the data validation?
Link to another html file after clicked.
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
This is the sample code from bootstrap, how can I add a link in this button while keep the data validation?
Link to another html file after clicked.
2
Answers
You need to wrap it into
form
Then all your data will be available on
yourPage.php
If you’re using other language you need to look up how to get the data.
To add a link to a submit button in HTML while maintaining data validation, you can use JavaScript or jQuery to achieve the desired functionality. Here are a few options you can consider:
Using JavaScript:
onclick
event handler to the button and usewindow.location.href
to redirect to the desired HTML file.Using jQuery:
window.location.href
to redirect to the desired HTML file.Please note that these solutions will redirect the user to another HTML file upon clicking the button. However, it’s important to mention that using a submit button for navigation purposes may not be semantically correct according to HTML standards. The purpose of a form is typically to collect and submit user data, whereas using a submit button for navigation goes against this convention.
If you want to maintain data validation while navigating to another page, you may need to handle the validation logic separately. You can use JavaScript or jQuery to validate the form fields before redirecting the user to another page.
Remember to replace
'path/to/your/file.html'
with the actual path of the HTML file you want to link to.I hope this helps!