Jump to content


Photo

live check input if exist or not?


  • Please log in to reply
No replies to this topic

#1 JaysonDotPH

JaysonDotPH

    Advanced Member

  • Members
  • PipPipPip
  • 177 posts
  • LocationPhilippines

Posted 02 May 2014 - 09:26 PM

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

 

image.png

<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 by JaysonDotPH, 02 May 2014 - 09:27 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com