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, "")
가 무슨 뜻인지 모르겠습니다.
이상한 문자(?)들이 너무 많아서... ^^;
아이님께서 입력하신 코드는 입력된 값이 정규식과 일치하는 부분을 삭제 하는 일을 합니다.
더 자세한 내용은 아래 사이트를 참조하세요.
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...
<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...
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...
(^\s*)|(\s*$) 결국 문자열 앞뒤의 스페이스를 없애는
VB 의 trim() 과 같은 역할이 되겠네요...
"착한아이" <maxp...@hotmail.com> wrote in message
news:ucC%23sAniE...@TK2MSFTNGP09.phx.gbl...