티스토리 뷰
728x90
1. oninput 이벤트, 정규식, replace() 함수 활용
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"
<th>연락처</th>
<td>
<input type="text" id="info01" name="info04" value="" maxlength="3" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<span class="date">-</span>
<input type="text" id="info02" name="info05" value="" maxlength="4" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<span class="date">-</span>
<input type="text" id="info03" name="info06" value="" maxlength="4" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
</td>
</tr>
2. input type "number"
<input type="number">
<th>연락처</th>
<td>
<input type="number" id="info01" name="info04" value="" maxlength="3">
<span class="date">-</span>
<input type="number" id="info02" name="info05" value="" maxlength="4">
<span class="date">-</span>
<input type="number" id="info03" name="info06" value="" maxlength="4">
</td>
</tr>
3. 입력된 keycode 체크하기
<input type="text" onkeypress="return checkNumber(event)">
function checkNumber(event) {
if(event.key === '.'
|| event.key === '-'
|| event.key >= 0 && event.key <= 9) {
return true;
}
return false;
}
'js' 카테고리의 다른 글
[JavaScript] Location URL 정보 가져오기 (0) | 2022.01.18 |
---|---|
JSON 객체의 parse / stringify 차이 (0) | 2022.01.10 |
[jQuery] <input type= 'file' 이미지 선택 시 미리보기 구현 (1) | 2021.12.15 |
[JavaScript] Input elements should have autocomplete attributes (0) | 2021.12.01 |
[jQuery]동적 append 후 .find() .remove() (0) | 2021.11.19 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- js 전자서명
- js라이브러리사용
- 전자서명기능구현
- MSsql
- Oracle
- ios app 개발
- jsignature.min.js
- swift 계산기
- PostgreSQL
- 트리구조jstree
- xcode swift memo
- Swift
- 전자서명개발
- xcode12.5.1
- Xcode
- spring annotation
- mysql
- for in문제
- jxls
- draganddrop file
- jxls 엑셀
- fullcalendar js
- swift 메모장 만들기
- 달력기능개발
- js file drag
- js달력
- file drag drop
- js라이브러리
- for in 주의
- https://www.jstree.com/
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함