v0.9.15e - made nameCheck for guides

This commit is contained in:
2020-08-17 08:23:48 +02:00
parent 604d5dad19
commit fce970de65
8 changed files with 142 additions and 19 deletions
@@ -23,10 +23,11 @@
}
</style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<h1>Opret Vejledning</h1>
<h1 id="errormesseages" >Opret Vejledning</h1>
<form method="post" action="{{ route("guides.store") }}" enctype="multipart/form-data">
@csrf
<label for="title">Titel guiden</label>
<label hidden id="error" for="errormesseages">Navn findes allerede</label>
<input type="text" name="name" id="title" required>
<div id="editor"></div>
<textarea name="guide_articles" class="d-none" id="hiddenArea"></textarea>
@@ -38,7 +39,7 @@
</label>
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri):</label>
<input id="fileuploade" type="file" name="resource">
<input type="submit" class="btn btn-dark text-white" value="Opret">
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
@@ -79,5 +80,59 @@
}
);
});
$(document).ready(function () {
$value = $('#title').val();
$.ajax({
type: 'get',
url: '{{route('guides.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);
}
});
});
$('#title').on('keyup', function () {
$value = $(this).val();
console.log($value);
$.ajax({
type: 'get',
url: '{{route('guides.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