General Pattern for Using 3rd Party Ajax Validation in a form

Hi, all. I just wanted to confirm a general pattern for interrupting the normal Ajax validation of a form to use a 3rd party for validation of data using jquery.

I wasn’t able to find enough documentation for how I would go about it

In the view I would use something along the lines of:

<div >

    <?php $form = ActiveForm::begin([
        'id'           => 'demo-form',
        'validateOnSubmit' => false
    ]); ?>
    <?= $form->field($model, 'username'); ?>
    <?= Html::submitButton('Submit') ?>
    <?php ActiveForm::end(); ?>

    $( "#demo-form" ).submit(function( event ) {
        // AJAX submitting username to 3rd party service and returning true if not in use and false if already in use

Is there a better way than this? If so I can’t find it.

If there isn’t a good resource for this do you think this would be a good wiki article to include?