정규식으로 바꿨습니다.
많이 돌아 다니는 소스이긴 하지만..
<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에서 이동 됨]
게시판 목록
팁게시판
디자인과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5677 |
패션리스트
|
10년 전 | 2364 | |
| 5676 |
패션리스트
|
10년 전 | 2325 | |
| 5675 | 10년 전 | 2245 | ||
| 5674 |
|
10년 전 | 1377 | |
| 5673 |
|
10년 전 | 2125 | |
| 5672 |
|
10년 전 | 1742 | |
| 5671 |
|
10년 전 | 2815 | |
| 5670 | 10년 전 | 1204 | ||
| 5669 |
|
10년 전 | 2004 | |
| 5668 | 10년 전 | 1098 | ||
| 5667 | 10년 전 | 1371 | ||
| 5666 |
|
10년 전 | 1708 | |
| 5665 |
|
10년 전 | 1265 | |
| 5664 |
|
10년 전 | 1001 | |
| 5663 | 10년 전 | 2449 | ||
| 5662 | 10년 전 | 995 | ||
| 5661 |
AniNest
|
10년 전 | 2691 | |
| 5660 |
untitled
|
10년 전 | 2314 | |
| 5659 |
프로그래머7
|
10년 전 | 1702 | |
| 5658 |
untitled
|
10년 전 | 2314 | |
| 5657 |
untitled
|
10년 전 | 1842 | |
| 5656 |
untitled
|
10년 전 | 2603 | |
| 5655 |
|
10년 전 | 2720 | |
| 5654 | 10년 전 | 1381 | ||
| 5653 |
|
10년 전 | 1785 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기