Answer the question
In order to leave comments, you need to log in
Why is the validator not validating?
function onUserRegister(){
$lang = [
'required' => 'Все поля обязательны к заполнению!',
'first_name.required' => 'Введите ваше имя!',
];
$data = post();
$rules = [
'first_name.required'=>'Поле обязательно к заполнению'
];
$validation = Validator::make($data, $rules, $lang);
if ($validation->fails()) {
throw new ValidationException($validation);
}
}
<form id="register" class="text-center" data-request="onUserRegister" data-request-validate>
<p class="status"></p>
<label class="grey-text" class="grey-text" for="first_name">Имя</label>
<input type="text" id="first_name" class="form-control" name="first_name">
<br>
<label class="grey-text" for="first_name">Фамилия</label>
<input type="text" id="surname" class="form-control" name="surname">
<br>
<label class="grey-text" for="email">E-mail</label>
<input type="text" id="email" class="form-control" name="email">
<br>
<label class="grey-text" for="password">Пароль</label>
<input type="password" id="password" class="form-control" name="password">
<div class="mt-4">
<button class="btn btn-info btn-md mb-4 waves-effect waves-light" type="submit">Продолжить</button>
</div>
<div class="alert alert-danger" data-validate-error>
<p data-message></p>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question