1

I use codeignitor. Following is the jquery code I use for login form validation.

            $("#login_form").validate({
                errorPlacement: function(error, element) { },// Disable error messages
                debug:true,
                rules: {
                    username: 
                    {
                        required: true,
                        remote: 
                        {
                            url: "http://localhost/my_site/index_page/validate_username_password",
                            type: "post",
                            data: {
                            password: function(){ return $("#password").val(); } //Password is sent alongside the username
                            }
                        }
                    },
                password:{required:true}
                },
                highlight: function(username, errorClass) 
                {
                    $(username).fadeOut(function() 
                    {
                        $(username).fadeIn();
                    });
                },
                submitHandler: function(form) // CALLED ON SUCCESSFUL VALIDATION
                {
                    window.location.replace='http://localhost/my_site/index_page';
                }
            });

By this code, after success validation, I am expecting my page to get redirected to

http://localhost/my_site/index_page

but it is not.

I use codeignitor.

Karthik
  • 365
  • 1
  • 3
  • 16

3 Answers3

1

window.location.replace() is a function, use it as:

window.location.replace('http://localhost/my_site/index_page');
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
0

Check this link and see the proposed solutions.

Before jumping to any conclusion make sure submitHandler: function(form) {} is indeed fired.

Community
  • 1
  • 1
Avram Cosmin
  • 383
  • 7
  • 8
0

Try this:

Use

document.location='http://localhost/my_site/index_page';

instead of

window.location.replace='http://localhost/my_site/index_page';

in your code...

ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42