Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

athulpraj's avatar

jquery validate plugin remote method

i'm trying to validate using jquery plugin to check if a field is available using remote method .. but it is not working .. can someone check my code and tell me where i went wrong

$("#installationForm").validate({
                rules: {
                    name: "required",
                    pageurl: {
                        required: true,
                        minlength: 5,
                    },
                    game_status: "required",
                    release_date: {
                        required: true,
                        date: true,
                        remote: {
                            url: "{{action('Api\ApiController@getPageNameAvailability')}}",
                            type: 'GET',
                            delay: 1000,
                            message: 'The pageurl is not available.'
                        }
                    },
                    messages: {
                        name: "Enter the Game Name",
                        pageurl: {
                            required: "A unique game URL is required",
                            minlength: "URL must be of atleast 5 characters",

                        },
                        game_status: "Select a game status",
                        release_date: {
                            required: "Enter a Release date",
                            date: "Entered value not valid"
                        }
                    }
                }
            });

and the controller

public function getPageNameAvailability(){
        $input = \Request::all();
        $rules = array(
            'pageurl' => array('required', 'max:70', 'min:5', 'regex:/^[a-zA-Z0-9\_]+$/'),
        );

        $validation = \Validator::make($input, $rules);

        if ($validation->fails())
        {
            return ['valid'=>false];
        }
        $ukey = strtolower(Input::get('pageurl'));
        $username = UserNameList::username($ukey)->first();
        if(!$username){
            return ['valid'=>true];
        } else {
            return ['valid'=>false];
        }
    }

all other validations are working except the remote method

0 likes
0 replies

Please or to participate in this conversation.