Thush
Thush

Reputation: 1

Page redirect using call back function in javascript

I have created a validate function in Javascript for validation the form. Now I want to create another function redirect which is to be used as a call back function to redirect to another html page after form validation..how to do that??

Upvotes: 0

Views: 1299

Answers (1)

net-js
net-js

Reputation: 129

you can use the location.replace() function like this -

validate(sometext, redirect)

function validate(text, callback){
  //somelogic
  callback("https://google.com")
}

function redirect(url) {
  location.replace(url)
}

Upvotes: 1

Related Questions