Welcome Guest, Not a member yet? Register   Sign In
jquery validation
#1

[eluser]tj[/eluser]
hai am new to codeigniter my requirement is i have a checkbox on clicking the checkbox a text box is shown and i need to add validation to this text box.my problem is all thes fields are in a foreach and increment according to the count help me guys

<? $i=0;?>
<? foreach ($info as $link): ?>
<DIV>&lt;INPUT type="checkbox" name="check&lt;?=$i?&gt;" &gt;&lt;a href="&lt;?=$link;?&gt;">&lt;?=$link;?&gt;</a></DIV>
<p id="container&lt;?=$i?&gt;" style="display:none">
Enter Tag
&lt;INPUT type="text" name="tag&lt;?=$i?&gt;" id="tag&lt;?=$i?&gt;"&gt;
</p>
&lt;INPUT type="hidden" name="url&lt;?=$i?&gt;" id="url&lt;?=$i?&gt;" value="&lt;?=$link?&gt;"&gt;
&lt;? $i++;?&gt;
&lt;? endforeach;?&gt;
#2

[eluser]Thomas Edwards[/eluser]
tj, you should simply call the $i with the jquery function.

Code:
&lt;input type="checkbox" name="check&lt;?=$i?&gt;" onclick="showtext('&lt;?=$i?&gt;')" /&gt;

Then in your JavaScript.

Code:
function showtext(id)
{
    $('#tag'+id).show();
}
#3

[eluser]tj[/eluser]
hai tnx for u reply .but my real problem is not to display that text box i want to validate this text box
#4

[eluser]saidai jagan[/eluser]
Code:
function showtext(id)
{
    var textvalue = $('#tag'+id).val();
if(textvalue == '')
  alert('Give value');
}
#5

[eluser]tj[/eluser]
tnx saidai jagan but i need something like jquery message not a popup
#6

[eluser]Sam Granger[/eluser]
replace the alert line with:
$('#error').html('error goes here');

add the following div to your html where you want the error to appear: <div id="error"></div>




Theme © iAndrew 2016 - Forum software by © MyBB