update terbaru
This commit is contained in:
parent
b6a700496c
commit
e9b712409c
|
|
@ -22,22 +22,22 @@ public function register(Request $request): RedirectResponse
|
|||
{
|
||||
// Validasi dasar terlebih dahulu
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|min:12|max:255',
|
||||
'name' => 'required|string|min:8|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users|regex:/@gmail\.com$/|regex:/^\S+$/',
|
||||
'phone' => 'required|string|regex:/^[0-9]+$/|min:12|max:20|regex:/^\S+$/',
|
||||
'phone' => 'required|string|regex:/^\+62[0-9]{9,15}$/|max:20',
|
||||
'address' => 'required|string|min:12|max:500',
|
||||
'password' => 'required|string|min:8|confirmed|regex:/^\S+$/',
|
||||
'agree' => 'required|accepted',
|
||||
], [
|
||||
'name.required' => 'Nama wajib diisi.',
|
||||
'name.min' => 'Nama minimal harus 12 karakter.',
|
||||
'name.min' => 'Nama minimal harus 8 karakter.',
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Format email tidak valid.',
|
||||
'email.unique' => 'Email sudah digunakan.',
|
||||
'email.regex' => 'Email harus menggunakan domain @gmail.com dan tidak boleh mengandung spasi.',
|
||||
'phone.required' => 'Nomor telepon wajib diisi.',
|
||||
'phone.regex' => 'Nomor telepon hanya boleh berisi angka dan tidak boleh mengandung spasi.',
|
||||
'phone.min' => 'Nomor telepon minimal harus 12 karakter.',
|
||||
'phone.regex' => 'Nomor telepon harus diawali dengan +62 dan hanya boleh berisi angka.',
|
||||
// 'phone.min' => 'Nomor telepon minimal harus 12 karakter.',
|
||||
'address.required' => 'Alamat wajib diisi.',
|
||||
'address.min' => 'Alamat minimal harus 12 karakter.',
|
||||
'password.required' => 'Password wajib diisi.',
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ class="form-control @error('name') is-invalid @enderror"
|
|||
value="{{ old('name') }}"
|
||||
required
|
||||
autocomplete="name"
|
||||
placeholder="Minimal 12 karakter">
|
||||
placeholder="Minimal 8 karakter">
|
||||
</div>
|
||||
<div class="form-text text-muted">
|
||||
<small><i class="fas fa-info-circle"></i> Nama minimal harus 12 karakter</small>
|
||||
<small><i class="fas fa-info-circle"></i> Nama minimal harus 8 karakter</small>
|
||||
</div>
|
||||
@error('name')
|
||||
<div class="text-danger mt-1"><small>{{ $message }}</small></div>
|
||||
@enderror
|
||||
<div id="nameError" class="text-danger mt-1" style="display: none;">
|
||||
<small>Nama minimal harus 12 karakter</small>
|
||||
<small>Nama minimal harus 8 karakter</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -76,16 +76,16 @@ class="form-control @error('phone') is-invalid @enderror"
|
|||
name="phone"
|
||||
value="{{ old('phone') }}"
|
||||
required
|
||||
placeholder="081234567890">
|
||||
placeholder="+6281234567890">
|
||||
</div>
|
||||
<div class="form-text text-muted">
|
||||
<small><i class="fas fa-info-circle"></i> Hanya angka, minimal 12 karakter</small>
|
||||
<small><i class="fas fa-info-circle"></i> Harus diawali +62, contoh: +6281234567890</small>
|
||||
</div>
|
||||
@error('phone')
|
||||
<div class="text-danger mt-1"><small>{{ $message }}</small></div>
|
||||
@enderror
|
||||
<div id="phoneError" class="text-danger mt-1" style="display: none;">
|
||||
<small>Nomor telepon harus angka dan minimal 12 karakter</small>
|
||||
<small>Nomor telepon harus diawali +62 dan hanya boleh berisi angka</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ class="form-control"
|
|||
// Real-time validation
|
||||
nameInput.addEventListener('input', function() {
|
||||
const nameError = document.getElementById('nameError');
|
||||
if (this.value.length < 12) {
|
||||
if (this.value.length < 8) {
|
||||
nameError.style.display = 'block';
|
||||
this.classList.add('is-invalid');
|
||||
} else {
|
||||
|
|
@ -258,9 +258,9 @@ class="form-control"
|
|||
const numberPattern = /^[0-9]+$/;
|
||||
|
||||
// Remove non-numeric characters
|
||||
this.value = this.value.replace(/[^0-9]/g, '');
|
||||
|
||||
if (!numberPattern.test(this.value) || this.value.length < 12) {
|
||||
|
||||
if (!/^\+62[0-9]{9,15}$/.test(this.value) && this.value.length > 0) {
|
||||
phoneError.style.display = 'block';
|
||||
this.classList.add('is-invalid');
|
||||
} else {
|
||||
|
|
@ -340,8 +340,7 @@ function checkPasswordMatch() {
|
|||
isValid = false;
|
||||
}
|
||||
|
||||
const numberPattern = /^[0-9]+$/;
|
||||
if (!numberPattern.test(phoneInput.value) || phoneInput.value.length < 12) {
|
||||
if (!/^\+62[0-9]{9,15}$/.test(phoneInput.value)) {
|
||||
document.getElementById('phoneError').style.display = 'block';
|
||||
phoneInput.classList.add('is-invalid');
|
||||
isValid = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue