Jump to content

live check input if exist or not?


Yohanne

Recommended Posts

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.