정규식으로 바꿨습니다.
많이 돌아 다니는 소스이긴 하지만..
<SCRIPT LANGUAGE="JavaScript">
<!--
String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g, "");}
String.prototype.ltrim = function() {return this.replace(/(^\s*)/g, "");}
String.prototype.rtrim = function() {return this.replace(/(\s*$)/g, "");}
<!--
String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g, "");}
String.prototype.ltrim = function() {return this.replace(/(^\s*)/g, "");}
String.prototype.rtrim = function() {return this.replace(/(\s*$)/g, "");}
function res(){
if(document.form.sel.value == "1")
document.form.rep.value = document.form.ok.value.trim();
if(document.form.sel.value == "2")
document.form.rep.value = document.form.ok.value.rtrim();
if(document.form.sel.value == "3")
document.form.rep.value = document.form.ok.value.ltrim();
}
//-->
</SCRIPT>
</HEAD>
if(document.form.sel.value == "1")
document.form.rep.value = document.form.ok.value.trim();
if(document.form.sel.value == "2")
document.form.rep.value = document.form.ok.value.rtrim();
if(document.form.sel.value == "3")
document.form.rep.value = document.form.ok.value.ltrim();
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<form name="form">
<select name="sel">
<option value="1">Trim</option>
<option value="2">rTrim</option>
<option value="3">lTrim</option>
</select>
<input type="text" name="ok" >
<input type="text" name="rep" >
<input type="button" value="확인" onclick="res();"><br>
</form>
</BODY>
</BODY>
[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 30 |
아우겐나이스
|
21년 전 | 4042 | |
| 29 |
아우겐나이스
|
21년 전 | 4433 | |
| 28 |
아우겐나이스
|
21년 전 | 3456 | |
| 27 | 21년 전 | 5822 | ||
| 26 | 21년 전 | 3093 | ||
| 25 | 21년 전 | 6071 | ||
| 24 | 18년 전 | 3642 | ||
| 23 | 21년 전 | 3630 | ||
| 22 | 21년 전 | 4241 | ||
| 21 | 21년 전 | 3812 | ||
| 20 | 21년 전 | 4213 | ||
| 19 | 21년 전 | 6675 | ||
| 18 | 21년 전 | 4731 | ||
| 17 | 21년 전 | 6982 | ||
| 16 | 21년 전 | 4165 | ||
| 15 | 21년 전 | 2625 | ||
| 14 | 21년 전 | 4964 | ||
| 13 | 21년 전 | 3396 | ||
| 12 |
Recluse
|
21년 전 | 3869 | |
| 11 |
아우겐나이스
|
21년 전 | 3566 | |
| 10 |
Recluse
|
21년 전 | 3389 | |
| 9 | 21년 전 | 3978 | ||
| 8 | 21년 전 | 5159 | ||
| 7 | 21년 전 | 4754 | ||
| 6 | 21년 전 | 5672 | ||
| 5 | 21년 전 | 4108 | ||
| 4 | 21년 전 | 4829 | ||
| 3 | 21년 전 | 4735 | ||
| 2 | 21년 전 | 3233 | ||
| 1 | 22년 전 | 4336 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기