I hope someone can provide a quick fix to this being I'm a novice at this stuff!!
I have several text fields in a form. I want to ensure that a hidden checkbox (rMoths) field is ticked if any of the defined fields (e.g. Flower) contains a value.
-
How do I do this with multiple fields, say Flower, Robin, Starling, Pigeon and ensure that the checkbox remains ticked unless all defined fields have their values removed?
-
I need to ensure that if a 'space' (space bar) character is entered into any of the defined fields and no other character (i.e. a true value) is entered then the field is ignored and does not trigger the checkbox to be ticked.
Using JQuery script I have this working for a single field (Flower) see code below but need to apply to multiple named fields listed in point 1 above and address point 2.
<script>
$(document).ready(function() {
$("input.Flower").on("keyup blur", function() {
$("input.Moth").prop("checked", this.value != "");
});
$("input.Moth").click(function() {
return false;
});
});
</script>
Many thanks
Steve
Aucun commentaire:
Enregistrer un commentaire