First off, I'd like to apologize for the horrid title there, but it was the best way I could think of summing up my issue.
Currently, I use a jQuery
script that checks, on blur
on an input:text
, that the text value of the input is greater than a certain amount. If not, the input is highlighted red - but what I'd like to happen next, is to have a <p>
in an adjacent column to have it's text changed.
My HTML looks like this:
<tr>
<td width="15%"><label for="example">Hello world</label></td>
<td width="70%"><input type="text" class="" id="example" value=""/></td>
<td width="15%"><p name="example"></p></td>
</tr>
And my jQuery/css is :
<style type="text/css">
.fail{
border:2px red solid;
}
</style>
<script type="text/javascript">
/* Inline, onBlur validation
Text */
$('input:text').blur(function() {
if ($(this).val().length <= 2) {
$(this).attr('class', 'fail');
}else{$(this).attr('class', '');}
});
</script>
Is it possible, on blur
to somehow call the next element with the same name
as the selected input's id
, and then change it's text? I know this must be a tough dynamic puzzle to solve, but it's something I really need.
In the past, I achieved the same effect by repeating the code for every element, but that's not really suitable here.
Thank you for any advice you can give me!