javascript - Send Request to PHP file only when input reaches X characters -


i using java script code data sql. want send request php file when input field has 15 characters. used onkeyup="if(this.value.length>14)" didn't work. can 1 please modify java script code.. please

change html this:

 <input type="text" name="name" maxlength="15" id="name" onkeyup="check_length(this)"  /> 

and add function javascript:

function check_length(thisobject){      if(thisobject.value.length>14){ajaxfunction(thisobject.value)} } 

edit:

this happens when define functions in head part , call them, when document not yet initialized. move script part, initialization happens , try out.

i place sample code (save in blank html file , test it):

<input type="text" name="name" maxlength="15" id="name" onkeyup="check_length(this)"  /> <script> function check_length(thisobject){      if(thisobject.value.length>14){ajaxfunction(thisobject.value)} } function ajaxfunction(thisobjectvalue) {     console.log(thisobjectvalue);     /// things .... } </script> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -