order form
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 199 KiB |
@@ -0,0 +1,90 @@
|
||||
function validate(what, text) {
|
||||
console.log('Validate '+what);
|
||||
if (what == 'quantity') {
|
||||
var re = /^[0-9]{1,2}$/;
|
||||
} else if (what == 'email') {
|
||||
var re = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;
|
||||
} else if (what == 'delivery_address') {
|
||||
var re = /^notpermitted$/;
|
||||
} else if (what == 'billing_address') {
|
||||
var re = /^notpermitted$/;
|
||||
} else {
|
||||
var re = /^notpermitted$/;
|
||||
}
|
||||
return re.test(text);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
console.log("I am ready!!!");
|
||||
$("#quantity_exclamation").hide();
|
||||
$("#email_exclamation").hide();
|
||||
|
||||
$("#modal-save").click(function() {
|
||||
// Validation Code
|
||||
var is_valid = true;
|
||||
if (!validate('quantity',$('#quantity').val())) {
|
||||
$('#quantity_errormsg').html('Ungültige Anzahl');
|
||||
$("#quantity").addClass("is-danger");
|
||||
$("#quantity_exclamation").show();
|
||||
is_valid = false;
|
||||
} else {
|
||||
$('#quantity_errormsg').html('');
|
||||
$("#quantity").removeClass("is-danger");
|
||||
$("#quantity_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!validate('email',$('#email').val())) {
|
||||
$('#email_errormsg').html('Ungültige E-Mail Adresse');
|
||||
$("#email").addClass("is-danger");
|
||||
$("#email_exclamation").show();
|
||||
is_valid = false;
|
||||
} else {
|
||||
$('#email_errormsg').html('');
|
||||
$("#email").removeClass("is-danger");
|
||||
$("#email_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!(is_valid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "order_tracker",
|
||||
type: "post", //send it through post method
|
||||
dataType: "json",
|
||||
data: {
|
||||
quantity: $('#quantity').val(),
|
||||
email: $('#email').val(),
|
||||
delivery_address: $("#delivery_address").val(),
|
||||
billing_address: $("#billing_address").val()
|
||||
},
|
||||
success: function(response) {
|
||||
console.log('order success');
|
||||
if (response.rc == 0) {
|
||||
console.log('response.rc == 0');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.log('order error');
|
||||
//Do Something to handle error
|
||||
}
|
||||
});
|
||||
|
||||
console.log("order");
|
||||
$("#modal").removeClass("is-active");
|
||||
|
||||
});
|
||||
|
||||
$("#modal-close").click(function () {
|
||||
$("#modal").removeClass("is-active");
|
||||
});
|
||||
|
||||
function callback() {
|
||||
console.log("Callback Funktion wird aufgerufen");
|
||||
$('#quantity').focus().select();
|
||||
}
|
||||
|
||||
setTimeout(callback, 10);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user