One way is using some Javascript:
- Select urls
- Grab the
<form>html element - Run a function to open a new tab when user presses submit button.
//define the urls
const urls = {
success: "https://google.com"; //when the form is valid,
tryAgain:"https://freecodecamp.com" //when form is not valid
}
const form = document.getElementById('survey-form'); //grab the HTML-element
const executeWhenUserSubmitsForm = function (e){
e.preventDefault(); //read about preventDefault()
form.checkValidity()? window.open(urls.success):
window.open(urls.tryAgain);
}
form.addEventListener('submit', (e)=>executeWhenUserSubmitsForm)