일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- ajax
- lsusb
- PHP GCM
- XMLHTTP
- utf-8
- include
- synology
- Getrows
- println
- disabled
- 시놀로지
- 커널
- jQuery
- 크로스 컴파일
- RTL88x2BU
- 따라다니는 배너
- DS718+
- FileSystemObject
- form
- 무선랜카드
- jquery 레이어
- replace
- AC1300
- javascript
- euc-kr
- Injection
- submit
- readonly
- SQL Injection
- ASP
- Today
- Total
아는 것이 좋은 것이다.
[jQuery] form 유효성검사 본문
<html>
<head>
<title>테스트 페이지</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<form action="">
<input type="text" name="name" id="name" /><br>
<input type="text" name="id" id="id" /><br>
<input type="text" name="email" id="email" /><br>
<input type="submit" value="전송" />
</form>
<script type="text/javascript">
$(document).ready(function(){
var RegexEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i; //이메일 요휴성검사
var RegexName = /^[가-힣]{2,4}$/; //이름 유효성 검사 2~4자 사이
var RegexId = /^[a-z0-9_-]{3,16}$/; //아이디 유효성 검사 316자 사이
var RegexTel = /^[0-9]{8,11}$/; //전화번호 유효성 검사
$("form").submit(function(){
if ( !RegexName.test($.trim($("#name").val())) )
{
alert("이름 오류");
$("#name").focus();
return false;
}
if ( !RegexName.test($.trim($("#id").val())) )
{
alert("아이디 오류");
$("#id").focus();
return false;
}
if ( !RegexEmail.test($.trim($("#email").val())) )
{
alert("이메일 오류");
$("#email").focus();
return false;
}
});
});
</script>
</body>
</html>
'jQuery' 카테고리의 다른 글
[jQuery] asp, php 사용하지 않고 include 하기 (0) | 2014.07.13 |
---|---|
[jQuery] 제이쿼리 충돌 방지, 막기 (0) | 2014.07.09 |
[jQuery] input 쓰기, 읽기, 활성화, 비활성화 - readonly, disabled (0) | 2014.07.03 |
[jQuery] 문자열 입력제한 (0) | 2014.06.27 |
[jQuery] 이메일 직접입력, select 선택입력 (0) | 2014.06.25 |