스페이스바, 개행검사 > script

본문 바로가기
사이트 내 전체검색

script

스페이스바, 개행검사

페이지 정보

작성자 서방님 댓글 0건 조회 155회 작성일 07-08-09 18:12

본문

전체 내용이 스페이스바와 개행으로만 이루어져 있다면 formElm.value == "" 로는 검사가 불가능합니다.

정규식표현 /^s*$/.test(value) 을 이용하면 쉽게 검사할 수 있습니다.


<script>
  function checkSpaceAll(value)
  {
    if(/^s*$/.test(value))
    {
       alert('문자를 입력해주세요.');
       return false;
    }

    return true;
  }
</script>

<form onsubmit="return checkSpaceAll(this.content.value)">
 <textarea name="content"></textarea>
 <input type="submit" value="전송" />
</form>

댓글목록

등록된 댓글이 없습니다.

Total 846건 34 페이지
게시물 검색

회원로그인

접속자집계

오늘
64
어제
302
최대
1,347
전체
155,125
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.