fix:사업자번호 자동 하이픈 포맷팅 추가
- 입력 시 자동으로 000-00-00000 형식 적용 - 숫자만 입력해도 자동 변환 - 중복확인 시 형식 검증 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">사업자번호 <span class="text-red-500">*</span></label>
|
||||
<div class="flex gap-2">
|
||||
<input type="text" name="business_number" id="business_number" value="{{ old('business_number') }}" required
|
||||
placeholder="000-00-00000"
|
||||
placeholder="000-00-00000" maxlength="12"
|
||||
class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 @error('business_number') border-red-500 @enderror">
|
||||
<button type="button" id="checkBusinessNumber"
|
||||
class="px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition">
|
||||
@@ -120,6 +120,25 @@ class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition"
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
// 사업자번호 자동 포맷팅 (000-00-00000)
|
||||
document.getElementById('business_number').addEventListener('input', function(e) {
|
||||
let value = e.target.value.replace(/[^0-9]/g, ''); // 숫자만 추출
|
||||
|
||||
if (value.length > 10) {
|
||||
value = value.substring(0, 10); // 최대 10자리
|
||||
}
|
||||
|
||||
// 하이픈 삽입 (3-2-5 형식)
|
||||
if (value.length > 5) {
|
||||
value = value.substring(0, 3) + '-' + value.substring(3, 5) + '-' + value.substring(5);
|
||||
} else if (value.length > 3) {
|
||||
value = value.substring(0, 3) + '-' + value.substring(3);
|
||||
}
|
||||
|
||||
e.target.value = value;
|
||||
});
|
||||
|
||||
// 중복 확인
|
||||
document.getElementById('checkBusinessNumber').addEventListener('click', function() {
|
||||
const businessNumber = document.getElementById('business_number').value;
|
||||
const resultEl = document.getElementById('businessNumberResult');
|
||||
@@ -130,6 +149,13 @@ class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition"
|
||||
return;
|
||||
}
|
||||
|
||||
// 형식 검증 (000-00-00000)
|
||||
if (!/^\d{3}-\d{2}-\d{5}$/.test(businessNumber)) {
|
||||
resultEl.textContent = '사업자번호 형식이 올바르지 않습니다. (000-00-00000)';
|
||||
resultEl.className = 'mt-1 text-sm text-red-500';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('{{ route("sales.prospects.check-business-number") }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user