<!doctype html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script> </head> <body> <div> <label for="user_Email">이메일</label><input type="text" name="user_Email" id="user_Email" maxlength="40" placeholder="이메일 주소를 입력하세요." title="이메일" /> </div> <div> <label for="user_Phone">휴대전화</label><input type="text" id="user_Phone" maxlength="11" title="전화번호" /> </div> <button type="submit" class="btn_Submit">입력</button> <script type='text/javaScript'> $(document).ready(function(){ var $email = $('#user_Email'); var $phone = $('#user_Phone'); var $btSubmit = $('.btn_Submit'); $btSubmit.on('click', function(){ // 정규식 - 이메일 유효성 검사 var regEmail = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; // 정규식 -전화번호 유효성 검사 //var regPhone = /^((01[0|1|6|7|8|9])[1-9]+[0-9]{6,7})|(010[1-9][0-9]{7})$/; if( !$email.val() ){ alert('이메일주소를 입력 해 주세요'); $email.focus(); return false; } else if(!regEmail.test($email.val())) { alert('이메일 주소가 유효하지 않습니다'); $email.focus(); return false; } }); }); </script> </body> </html>
728x90
반응형
'WWWEB > Script' 카테고리의 다른 글
[tweenmax]트윈맥스 라이브러리 라이선스 (0) | 2016.10.11 |
---|---|
[js] URL가져오기 - JavaScript Window Location (window.location) (0) | 2016.09.12 |
마우스 드래그를 막고싶다면 (0) | 2016.08.18 |
버튼으로 overflow된 영역 스크롤하기 (0) | 2015.11.25 |
자바스크립트 \t, \n 등 이스케이프 시퀀스 (0) | 2012.12.20 |
jQuery API (0) | 2012.02.09 |
스크롤바 디자인 변경 (1) | 2010.07.07 |
폼 디자인 바꾸는 예제 (0) | 2010.06.15 |
댓글