sertificate_edit.blade.php
3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@extends('workers.cabinet_layout', ['title' => 'Редактирование стандартного документа - РекаМоре'])
@section('cabinet_content')
<h3 class="cabinet__h4 font30">Сертификат / документ</h3>
<form id="submit_form" name="submit_form" action="{{ route('worker.update_serificate', ['doc' => $doc->id]) }}" class="cabinet__inputs" method="GET">
@csrf
<input type="hidden" name="worker_id" id="worker_id" class="input" value="{{ $worker->id }}">
<div class="cabinet__body-item width100">
<div class="cabinet__inputs sertificate-form-inputs">
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Название сертификата:</label>
<div class="form-group__item">
@error('name')
<div class="error red">{{ $message }}</div>
@enderror
<input type="text" name="name" id="name" class="input" value="{{ old('name') ?? $doc->name }}">
</div>
</div>
<div class="cabinet__inputs-item form-group">
<label class="form-group__label">Действия сертификата до:</label>
<div class="form-group__item">
@error('end_begin')
<div class="error red">{{ $message }}</div>
@enderror
<input
type="text"
name="end_begin"
id="end_begin"
class="input"
placeholder="11.11.2011"
value="{{ old('end_begin') ?? date('d.m.Y', strtotime($doc->end_begin)) }}">
</div>
</div>
</div>
</div>
<div class="flex">
<button type="submit" class="button mr-10">Сохранить</button>
<a href="{{ route('worker.cabinet') }}" class="button button_light">Назад</a>
</div>
</form>
@endsection
@section('scripts')
<script>
$('#submit_form').on('submit', function (event) {
event.preventDefault();
var form = $(this);
var isValid = true;
form.find('.error-block').remove();
form.find('input').removeClass('border-red');
var name = form.find('[name="name"]').val().trim();
if (!name) {
form.find('[name="name"]').addClass('border-red');
isValid = false;
}
var endDate = form.find('[name="end_begin"]').val().trim();
var dateFormatRegex = /^\d{2}\.\d{2}\.\d{4}$/;
if (!endDate) {
form.find('[name="end_begin"]').addClass('border-red');
form.find('[name="end_begin"]').after('<span class="error-block">Поле "Действия сертификата до" обязательно для заполнения.</span>');
isValid = false;
} else if (!dateFormatRegex.test(endDate)) {
form.find('[name="end_begin"]').addClass('border-red');
form.find('[name="end_begin"]').after('<span class="error-block">Неверный формат даты (дд.мм.гггг).</span>');
isValid = false;
}
if (isValid) {
form.off('submit').submit();
}
});
</script>
@endsection