Hi guys how do i add a error message on this script in this line
$('input[name="s_postby"]').attr("required", true); // put the id of the input field that you whant required
<script type="text/javascript">
$('#catId').change(function(){
if( $('#catId').val() == "28" || $('#catId').val() == "29" || $('#catId').val() == "30" || $('#catId').val() == "31")
{
$("#postby").hide(); // change Posted By with ID you give to the div
$('input[name="s_postby"]').attr("required", false); // put the id of the input field that you whant required
}else
{
$("#postby").show(); // change Posted By with ID you give to the div
$('input[name="s_postby"]').attr("required", true); // put the id of the input field that you whant required
}
});
</script>
I need that the error will appears same way like the other error messages!
<script type="text/javascript">
$(document).ready(function(){
// Code for form validation
$("input[name=s_postby]").attr({
rules: {
yourEmail: {
required: true,
email: true
}
},
messages: {
yourEmail: {
required: "Email: this field is required.",
email: "Invalid email address."
},
message: {
required: "Message: this field is required.",
minlength: "Message: this field is required."
}
},
errorLabelContainer: "#error_list",
wrapper: "li",
invalidHandler: function(form, validator) {
$('html,body').animate({ scrollTop: $('h1').offset().top }, { duration: 250, easing: 'swing'});
},
submitHandler: function(form){
$('button[type=submit], input[type=submit]').attr('disabled', 'disabled');
form.submit();
}
});
});
</script>
hope you can help!
Thanks