I have a form with labels and input fields. When clicking into a field I want to style the field with CSS and display some information about the input requirements in a div under the label.
The focus() and blur() events add the classes for styling the field just fine but trying to show/ hide the info divs triggers the methods on ALL fields using $(this).siblings()
$(".input-field").focus(function() {
$(this).addClass("input-field-focus");
$(this).siblings(".label-info").show();
return false;
});
$(".input-field").blur(function() {
$(this).removeClass("input-field-focus");
$(this).siblings(".label-info").hide();
return false;
});
<label for="login">
User name:<br />
<div class="label-info">minimum 6 chararcters: letters, numbers and symbols - _ . @</div>
<input type="text" name="login" class="input-field" value="<?php echo (isset($_POST['login'])) ? $_POST['login'] : ""; ?>">
</label>