Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ÀÌ Äڵ尡 ¹«½¼¶æÀÌÁÒ? (ÀÚ¹Ù ½ºÅ©¸³Æ® )

0 views
Skip to first unread message

착한아이

unread,
Aug 25, 2004, 2:53:08 AM8/25/04
to
function hasValue(oField)
{
if (oField.value.replace(/(^\s*)|(\s*$)/g, "") == "")
return false;
else
return true;
}

function hasEditerValue(oField)
{
if (oField.value.replace(/ /g, " ").replace(/(^\s*)|(\s*$)/g, "") ==
"")
return false;
else
return true;
}

네이버 에서 사용 하고 있던데. 입력 폼 체크 하는 것 같은데.....
hasValue는 input file 값을 확인하는 것이고
hasEditerValue는 textarea 값을 확인하는 것입니다.... (아마도...)
정확히
replace(/(^\s*)|(\s*$)/g, "")
replace(/ /g, " ").replace(/(^\s*)|(\s*$)/g, "")
가 무슨 뜻인지 모르겠습니다.
이상한 문자(?)들이 너무 많아서... ^^;


유미짱

unread,
Aug 25, 2004, 5:29:40 AM8/25/04
to
말씀하신 이상한 문자들은 정규식에서 사용하는 것들입니다.
자세한 내용은 정규식을 찾아서 공부해보세요.

아이님께서 입력하신 코드는 입력된 값이 정규식과 일치하는 부분을 삭제 하는 일을 합니다.

더 자세한 내용은 아래 사이트를 참조하세요.

http://msdn.microsoft.com/library/en-us/script56/html/js56jsmthreplace.asp?frame=true


"착한아이" <maxp...@hotmail.com> wrote in message
news:ucC%23sAniE...@TK2MSFTNGP09.phx.gbl...

꿈꾸는 자

unread,
Aug 25, 2004, 11:55:25 AM8/25/04
to
제가 자주 사용하는 정규식을 모아놓은 스크립트 입니다.
잘 살펴보면 원하는 정규식을 만드는 것도 그리 어렵지 않고..
아주 유용하게 사용할 수 있습니다..^^

<html>
<body>
<script language=''javascript''>
function check()
{
var s=document.fm.x.value;

if( s.match(/[a-zA-Z_]\w*/g)==s ) {
alert("정확한 아이디");
}
if( s.match(/\d+/g)==s ) {
alert("숫자만 입력했음");
}
if( s.match(/0\d+\-\d\d+\-\d\d\d\d/g)==s ) {
alert("정확한 전화번호");
}
if( s.match(/01[16789]\-\d\d+\-\d\d\d\d/g)==s ) {
alert("정확한 휴대폰번호");
}
if( s.match(/\S/)==null ) {
alert("공백만 입력하면 안됨");
}
if( s.match(/[\w\-\~]+\@[\w\-\~]+(\.[\w\-\~]+)+/g)==s ) {
alert("정확한 메일주소");
}
}
</script>
<form name=fm>
<input type=text name=x>
<input type=button value=''체크'' onclick=''check()''>
</form>
</body>
</html>


"착한아이" <maxp...@hotmail.com> wrote in message
news:ucC%23sAniE...@TK2MSFTNGP09.phx.gbl...

Ssemi

unread,
Aug 25, 2004, 8:13:05 PM8/25/04
to
해당 정규식은

TRIM 에 대한 값이라고 보시면 됩니다 ^^

String Prototype 으로 만든 Trim 함수가 해당 정규식으로 짜여져 있거든요 :)

String.prototype.trim = function(str) {
str = this != window ? this : str;
return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

var tmp1 = 'dddd ';
var tmp2 = ' dddd ';
var tmp3 = ' dddd';
alert(tmp1.trim());
alert(tmp2.trim());
alert(tmp3.trim());


--
블로거 쎄미입니다 ^-^)/
http://www.ssemi.net


"착한아이" <maxp...@hotmail.com> wrote in message

news:ucC#sAniEH...@TK2MSFTNGP09.phx.gbl...

whohwa

unread,
Aug 25, 2004, 8:14:58 PM8/25/04
to
^ : 시작
\s : 스페이스
| : 또는 (or)
$ : 앞선 식이 문자열의 끝과 일치할때

(^\s*)|(\s*$) 결국 문자열 앞뒤의 스페이스를 없애는
VB 의 trim() 과 같은 역할이 되겠네요...


"착한아이" <maxp...@hotmail.com> wrote in message

news:ucC%23sAniE...@TK2MSFTNGP09.phx.gbl...

0 new messages