I am trying to show the response of the remote rule, possibly in the same place as the other responses. What I want to show is the response the PHP is sending me. I can easily show it in the console.log, but don't know how to show the result underneath the field
$("#conversionForm").validate({
// Specify the validation rules
ignore:[],
rules: {
"URL[]": {
required: true,
minlength: 3,
pattern: yt,
remote: {url:"checkdescription.php",
type: "post",
beforeSend: function () {
},complete: function (response) {
console.log(response.responseText); //This is what I would like to show
$(this).closest('.form-group').text(response.responseText) // This doesnt work
},
onkeyup: false
}
}
},
messages: {
"URL[]": {
required: "<div style='margin:3.4px 0 0 0'>This field is required</div>",
pattern: "<div style='margin:3.4px 0 0 0'>Enter a valid URL of the type https://www.youtube.com/watch?v=ZDO4I5aT0hg</div>",
minlength:"<div style='margin:3.4px 0 0 0'>Enter a valid URL</div>",
remote:<some invalid message dependent on the php response, too> //help here too
},
success: function(e) {
}
},
});
Basically I want to customize both error and success messages depending on the php response; if i can only send true or false back, then what other method do you think should i use?
Thank you
Edit: HTML
<form role="form" action="index.php" method="post" id="conversionForm">
<div id="to-append">
<div class="row" id="input-0">
<div class="col-xs-11 " >
<input type="text" class="form-control" id="youtubeURL-0" name="URL[]" placeholder="Enter your URL here">
</div>
</div>
</div>
<div class="row">
<div class="top-buffer col-xs-12" >
<button type="submit" id="btn-submit" name="submit" >Submit</button>
</div>
</div>
</form>
After this I add more divs exactly like .row #input-0 with jquery (#input-1, #input-2, etc) (appending them to #to-append). For each input, the remote php returns a different number, i want to show that number somwhere near the input field. Basically, show the validation remote answer