v0.10.2 - Full functioning AJAX check submit code on User controller create & edit

- Plus all other pages where you create or update something of an unique value
This commit is contained in:
Anders
2020-08-18 08:16:25 +02:00
parent c08933ba9b
commit e6e0e3c95d
4 changed files with 79 additions and 13 deletions
@@ -11,7 +11,7 @@
@section("content")
<h1 id="errormesseages" >Opret Bruger:</h1>
<form method="post" action="{{ route("users.store") }}" onsubmit="return myFunction()">
<form method="post" action="{{ route("users.store") }}" onsubmit="return checkInputs()">
@csrf
<label for="name_first">Fornavn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" required>
@@ -71,7 +71,7 @@
);
});
function myFunction() {
function checkInputs() {
var save = true;
$mail = $('#email').val();
$phone = $('#phone').val();
@@ -81,18 +81,18 @@
url: '{{route('users.nameCheck')}}',
data: {'mailCheck':$mail, 'phoneCheck':$phone},
success:function (data) {
if (data == 1) {
if (data == 'both') {
$("#erroremail").show(100);
$("#erroremail").css('color', 'red');
$("#errorphone").show(100);
$("#errorphone").css('color', 'red');
save = false;
} else if(data == 2){
} else if(data == 'email'){
$("#errorphone").hide();
$("#erroremail").show(100);
$("#erroremail").css('color', 'red');
save = false;
} else if (data == 3) {
} else if (data == 'phone') {
$("#erroremail").hide();
$("#errorphone").show(100);
$("#errorphone").css('color', 'red');