Home>
$(function () {
$("# button"). click (function (event) {
var form_data = {
id: $('# id'). val (),
add: $('# add'). val (),
};
var json = JSON.stringify (form_data);
$.ajax ({
type: "POST",
url: "c.php",
data: {json},
dataType: "json"
}). done (function (data) {
$("# p"). text (dat);
}). fail (function (XMLHttpRequest, textStatus, errorThrown) {
alert (errorThrown);
});
});
});
The current code will be sent even if the form data is empty, but I want to send it only when all items are filled. How can I do that?
-
Answer # 1
Related articles
- javascript - i want to prevent jquery datepicker from selecting a specific date
- javascript - i want to prevent vue from entering the input (type = number) value beyond the upper and lower limits!
- javascript - how to empty the contents of an element instead of innerhtml
- javascript - about sending and receiving files using json
- javascript - about sending and receiving multiple forms using flask + websocket
- javascript - i want to prevent files from being registered by dropping
- javascript - i want to prevent the button from working during modal display
- javascript - i want to prevent the content text from moving when creating a dropdown menu
- javascript - [js] i want to be able to scroll down on the other side after sending in chat
- javascript - how can i use a random function to prevent the same value from entering the same row when cells are automatically e
- javascript - how to prevent specific option tags from being output in a program that outputs the contents selected in the select
- javascript: array empty check
- javascript - i want to prevent multiple start of addeventlistener
Trends
I should be able to get the input value of the form with
if
statement.