Mình có hàm check-availability như này, đó là khi mình bấm vào Find out availability thì mới kiểm tra.
Mình muốn khi bấm username và tự động kiểm tra luôn thì phải làm sao.
Giống như Create Account của daynhauhoc á.
<div class="form-group">
<label for="user_login">
<?php _e('Username (E-mail Address)', 'iii-dictionary') ?>
</label>
<input id="user_login_signup" class="form-control" name="user_login" type="text" value="" required>
</div>
<a href="#" id="check-availability" class="check-availability">
<img style="height: 15px;" src="<?php echo get_template_directory_uri(); ?>/library/images/Icon_Questions.png">
Find out availability
<span class="icon-loading"></span>
</a>
$("#check-availability").click(function (e) {
e.preventDefault();
if (availability_checking) {
return;
}
var tthis = $(this);
var user_login = $("#user_login_signup").val().trim();
if (user_login != "") {
tthis.popover("destroy");
availability_checking = true;
tthis.find(".icon-loading").fadeIn();
$.getJSON(home_url + "/?r=ajax/availability/user", {user_login: user_login}, function (data) {
if (isValidEmail(user_login)) {
if (data [0] == 0) {
var p_c = '<span class="popover-alert"><?php _e('Not Available', 'iii-dictionary') ?></span>';
} else {
var p_c = '<span class="popover-alert"><?php _e('Available', 'iii-dictionary') ?></span>';
}
} else {
var p_c = '<span class="popover-alert"><?php _e('Invalid', 'iii-dictionary') ?></span>';
}
tthis.find(".icon-loading").fadeOut();
tthis.popover({
placement: "bottom",
content: p_c,
trigger: "click",
html: true
}).popover("show");
setTimeout(function () {
tthis.popover("hide")
}, 3000);
availability_checking = false;
});
}
});