I am trying to add the custom class for the failure messages (failure-message) which are in the php function the_validation_message($type) for the form validation. I tried to use the addClass using the jquery creating variables and storing the validation message type for different inputs but its not working. I have to apply the addClass only if the the_validation_message($type) appears like if the user enters wrong input then for this message the css should be applied.
Here is the code for the JavaScript portion for the html:
<script type="text/javascript">
$(document).ready(function(){
var email="<?php the_validation_message('email');?>";
$(email).addClass('failure-message');
var animals = "<?php the_validation_message('animals');?>";
$(animals.addClass('failure-message');
var date = "<?php the_validation_message('animals');?>";
$(date).addClass('failure-message');
});
</script>
The css file which contains the customed class .failure-message
.help-block, .failure-message
{
color:red;
animation-name: glow;
animation-duration: .5s;
animation-iteration-count: infinite;
animation-direction: alternate;
}
.failure-message
{
color:deeppink;
font-style: italic;
}
Thanks in advance