php - Input not detected in jQuery -
this not fire code, , i'm not sure why. i've tried .change
, .on('input')
, can find. problem simple. wrong?
$(function() { alert('hie'); //the min chars username var min_chars = 3; //result texts var characters_error = 'minimum amount of chars 3'; var checking_html = 'checking...'; //when button clicked $('#myusername').bind("change paste keyup", function() { //run character number check if ($('#myusername').val().length < min_chars) { //if it's bellow minimum show characters_error text $('#username_availability_result').html(characters_error); $('#checkuser').show(fast); alert('hsdi'); } else { //else show cheking_text , run function check $('#username_availability_result').html(checking_html); $('#checkuser').show(fast); check_availability(); alert('hi'); } }); }); //function check username availability function check_availability() { //get username var username = $('#myusername').val(); //use ajax run check $.post("../php/checkuser.php", {username: username}, function(result) { //if result 1 if (result == 1) { //show username available $('#username_availability_result').html(username + ' available'); } else { //show username not available $('#username_availability_result').html(username + ' not available'); } }); }
html
<tr> <td>username</td> <td><input type="text" name="username" placeholder="username" id="myusername"></td> </tr> <tr id="checkuser" style="display: none"> <td> </td> </tr>
check sample. removed "fast" parameter .show() call.
http://jsfiddle.net/juaning/psvs7/
from calls, let me know if fix problem.
$('#checkuser').show(fast);alert('hsdi');
$('#checkuser').show(fast);
Comments
Post a Comment