Yohanne Posted May 3, 2014 Share Posted May 3, 2014 (edited) Hi, i found source live check and i get hard to apply it in my work since i use multiple input text. i can add input text as many as i can and i can remove it as i can now i can't able use live check into other input text and does anyone can help. and i have no idea how to apply<span id="user-result"></span> into added input text. please help <script type="text/javascript"> // -------------------------------------------- function live check ------------------------ $(document).ready(function() { $("#code").keyup(function (e) { $(this).val($(this).val().replace(/\s/g, '')); var code = $(this).val(); if(code.length < 4){$("#user-result").html('');return;} if(code.length >= 4) { $("#user-result").html('<img src="images/ajax-loader.gif" />'); $.post('check_input.php', {'code':code}, function(data) { $("#user-result").html(data); }); } }); }); // ------------------------------------- function to add input_text ------------------------------ $(function() { var addDiv = $('#div_add'); var i = $('#div_add p').size() + 1; $('#addInput').live('click', function() { $('<p><input type = "text" id="code" required = "required" size="40" name="code[]' + i +'" value=""/><a href="#" id="remNew"><img src = "images/del.png"></a><span id="user-result"></span></p>').appendTo(addDiv); i++; return false; }); $('#remNew').live('click', function() { if( i > 1 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <label for="regularInput">Transaction number</label> <div id = "div_add"> <input type="text" id="code" name = "code[]" value = ""required = "required"><h3><a id = "addInput" href = "#"> <span id="user-result"></span><img src = "images/1398145891_square-add.png"></a></h3> </div> Edited May 3, 2014 by JaysonDotPH Quote Link to comment https://forums.phpfreaks.com/topic/288191-live-check-input-if-exist-or-not/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.