아래에 있는 trim을 보다가 조금 수정해봤습니다.
정규식으로 바꿨습니다.
많이 돌아 다니는 소스이긴 하지만..
<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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 227 | HTML |
hwatta
|
18년 전 | 5448 | |
| 226 | HTML | 18년 전 | 3095 | ||
| 225 | HTML | 18년 전 | 3649 | ||
| 224 | HTML |
mixdesign
|
18년 전 | 3952 | |
| 223 | HTML |
mixdesign
|
18년 전 | 5009 | |
| 222 | HTML | 18년 전 | 3136 | ||
| 221 | HTML | 18년 전 | 2990 | ||
| 220 | HTML |
|
18년 전 | 5125 | |
| 219 | HTML | 18년 전 | 4145 | ||
| 218 | HTML | 18년 전 | 5408 | ||
| 217 | HTML | 18년 전 | 2939 | ||
| 216 | HTML | 18년 전 | 3074 | ||
| 215 | HTML | 18년 전 | 3736 | ||
| 214 | HTML | 18년 전 | 3318 | ||
| 213 | HTML | 18년 전 | 2871 | ||
| 212 | HTML | 18년 전 | 4426 | ||
| 211 | HTML | 18년 전 | 3806 | ||
| 210 | HTML | 18년 전 | 3363 | ||
| 209 | HTML | 18년 전 | 3375 | ||
| 208 | HTML | 18년 전 | 2913 | ||
| 207 | HTML | 18년 전 | 4763 | ||
| 206 | HTML | 18년 전 | 4916 | ||
| 205 | HTML | 18년 전 | 4895 | ||
| 204 | HTML | 18년 전 | 5337 | ||
| 203 | HTML |
|
18년 전 | 4688 | |
| 202 | HTML | 18년 전 | 4741 | ||
| 201 | HTML | 18년 전 | 4237 | ||
| 200 | HTML | 18년 전 | 4926 | ||
| 199 | HTML | 18년 전 | 5547 | ||
| 198 | HTML | 18년 전 | 4091 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기