James
James

Reputation: 720

Foundation 6 Custom Abide with ajax call

I am attempting to create a custom abide validator to check if the username already exists. Everything I find online including here is for foundation 5 and the structure is completely different.

Foundation.Abide.defaults.validators['checkUser'] =
    function($el,required,parent) {
        console.log('checking');
        $.post( "func/checkUsername.php",{'user':$el.val()}, function( data ) {
        if(data.status==1){return true;}
        else{return false;}
        console.log('complete');
    });
};

This is my input field

<input type="text" id="usrnme" name="usrnme" required pattern="checkUser" value="" />

No matter what I do it will not submit to the console and it always comes up invalid.

Upvotes: 0

Views: 261

Answers (1)

EgidijusL
EgidijusL

Reputation: 1

pattern="checkUser" change to data-validator="checkUser"

<input type="text" id="usrnme" name="usrnme" required data-validator="checkUser" value="" />

Upvotes: 0

Related Questions