I want to use another page of my site to validate HTML form input. If the input is NOT valid, I want to show an error somewhere on my form page without reloading. And otherwise, if it IS valid, I want to submit the form normally.
After reading similar SO questions, I didn't found any exact solution, but actually invented my own, which works for me. Though, I still think that my solution is a bit weird, so I'm asking for proper ideas.
HTML:
<form id="form" method="POST"> ... some inputs ... </form>
<button id="submit" type="submit">Save</button>
<p id="errors"></p>
JS:
$('#form').submit(function (event) {
var formData = $(this).serializeArray();
event.preventDefault();
$.ajax({
type: "POST",
url: '/validate/',
data: formData,
success: function(data) {
if(!data)
{
$('#form').unbind('submit');
$('#submit').trigger('click');
}
else
{
$('#errors').text(data);
}
}
});
return false;
});
NB: It works as expected, I'm asking for better solutions.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have a large project that has many *html files and many *
I would like to create site and list in MS365 sharepointWhen I am referring documents related to MS sharepoint365,couldn't get much info
According to knowledge of mine,the responseend() should be called in after every response according to the nodejs api documenetation it which has described here
I had an app initiating course components like this: