black_belt
black_belt

Reputation: 6799

Jquery Validation Remote: displaying 1 as error message

I am trying to validate username field in my form using jquery validation plugin. I have the following custom rules.

username: {
            required: true,
            minlength: 2,
            remote: {
                url: '<?php echo base_url();?>mycontoller/myfunction',
                type: 'post'
            }

Now the problem is if my controller looks like following the plugin displays "1" as error message.

     if(1>2){
                echo False;
            } else{ echo True;}

But if I replace the code of the controller with following code, then it display an error message saying- the username already exists.

     if(1<2){
                echo False;
            } else{ echo True;}

Now could you please tell me how to get rid of that "1" or what is the proper way to send back the values(false or true) from controller to view.

Just for your information. I am displaying all my jquery validation error messages inside a span. like this.

         <span class="errormsg"></span>.

Upvotes: 0

Views: 2685

Answers (1)

Igor
Igor

Reputation: 3656

Here is an example where I'm sure you will find an answer: http://www.opencoder.co.uk/2010/07/jquery-remote-form-validation/

Upvotes: 2

Related Questions