Constant Learner
Constant Learner

Reputation: 525

Browser Back Button issue in asp.net

I have registration form, suppose there are 5 fields, and all are required i.e. mandatory. My problem is that when user login & fill 2 fields of that registration form & click browser back button, then I want to restrict user to same form & Show requiredField Validator messages of incomplete fields. So How can I fire Validation on browser back button & restrict user on same form.

Upvotes: 1

Views: 726

Answers (3)

Hans Kesting
Hans Kesting

Reputation: 39264

You can't disable the back button (see the other answers and their comments).

What you can do is check on every page whether the user is logged in. If not, redirect him to your login page. This way the user can't access the site without logging in, which I guess is what your client is really after.

Upvotes: 1

Aristos
Aristos

Reputation: 66641

The correct solution is to check right after user have been login, if he has complete the registration entries on database, and if not you redirect him to fill that data.

From your comments, to alert them a solution is to capture the onbeforeunload and check there if they have fill out everything or not, show your message.

Simple example, you just need here to place your conditions.

window.onbeforeunload = function() {
    return 'You have unsaved changes!';
}

Upvotes: 1

JSK NS
JSK NS

Reputation: 3446

You cannot affect browser behavior when the user clicks the Back button.

Upvotes: 3

Related Questions