JSFiddle - React, Tailwind, and code Playground
by rjurd
HTML
<div id="contact">
<form action="" method="post" id="quickcontact">Example:
<input type="text" size="30" id="s1" name="s1"></input>
<input type="submit" value="submit">
</form>
</div>
JavaScript
$('#quickcontact').submit(function(event) {
event.preventDefault();
//return false;
var info = [];
for (i = 1; i <= 13; i++) {
var input = $("#contact #" + "s" + i).val();
if (input === '') {
$("#" + "s" + i).css({
"border": "#F00 1px solid"
});
return false;
} else {
$("#" + "s" + i).css({
"border": "#ccc 1px solid"
});
}
info[i] = input;
}
var myurl = "mail.php";
myurl = "/echo/json";
$.ajax({
type: "POST",
url: myurl,
data: {
'json': {myarray: info}
},
success: function (data) {
alert(data);
//return false;
$.msgBox({
type: "info",
content: data.returnValue,
buttons: [{
value: "Ok"
}],
success: function (result, values) {}
});
},
error: function (a, b, c) {
alert("\n" + a + "\n" + b + "\n" + c + "\n");
},
dataType: "json"
});
});