v0.9.15g - NameCheck

This commit is contained in:
2020-08-17 09:21:47 +02:00
parent fce970de65
commit ea623a72ca
7 changed files with 140 additions and 6 deletions
@@ -23,10 +23,11 @@
}
</style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<h1>Opret Menuplan:</h1>
<h1 id="errormesseages" >Opret Menuplan:</h1>
<form action="{{ action('MenuPlanController@store') }}" method="post" enctype="multipart/form-data">
@csrf
<label for="week">Uge nr.</label>
<label hidden id="error" for="errormesseages">Menuplan findes allerede</label>
<input type="number" name="week" id="week" min="1" max="53" placeholder="1" required>
<div id="editor">
<h2 class="ql-align-center"><strong>Mandag:</strong></h2>
@@ -53,7 +54,7 @@
<input id="fileuploade" type="file" name="resource">
<input type="submit" class="btn btn-dark text-white" value="Opret Menuplan">
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret Menuplan">
</form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
@@ -107,6 +108,62 @@
}
change();
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#week').val();
$.ajax({
type: 'get',
url: '{{route('menuplans.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#week').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('menuplans.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script>
@endsection