(주)아이엔씨엔이 만든 웹솔루션 포탈 사이트 [골뱅이] 오픈!!
스크립트자료실
골뱅이Board
No.255   문자열에 공백이 있으면 + 부호로 이어줍니다
Name : 골뱅이 5552 hit / 2007-01-08 11:10:13

<script language='JavaScript'>

document.write('<st'+'yle>');
document.write('td {font-size:12px; font-family:굴림; text-decoration:none; }');
document.write('A:link,A:active,A:visited{text-decoration:none;font-size:12PX;color:#333333;}');
document.write('A:hover {text-decoration:none; color:ff9900}');
document.write('font { font-size: 9pt; }');
document.write('.cnj_input {background-color:rgb(240,240,240);border-width:1pt; height:16pt;cursor:hand;}');
document.write('.cnj_input2 {border-width:1; border-color:rgb(204,204,204); border-style:solid;}');
document.write('.cnj_input3 { border-width:1; border-style:solid; border-color:#000000; color:#0084D4; background-color:white;text-align:right;}');
document.write('.cnj_input4 { scrollbar-face-color: #FFCC33;scrollbar-shadow-color:  #ffffff;scrollbar-highlight-color: #F3f3f3;scrollbar-3dlight-color: #ffffff;scrollbar-darkshadow-color: #F3f3f3;scrollbar-track-color: #ffffff;scrollbar-arrow-color: #f9f9f9; }');
document.write('</st'+'yle>');
<!-- Original:  Mike McGrath (mike_mcgrath@lineone.net) -->
<!-- Web Site:  http://website.lineone.net/~mike_mcgrath -->

function convertSpaces(str) {
var out = "", flag = 0;
for (i = 0; i < str.length; i++) {
if (str.charAt(i) != " ") {
out += str.charAt(i);
flag = 0;
}
else {
if(flag == 0) {
out += "+";
flag = 1;
      }
   }
}
return out;
}
</script>
문자열에 공백이 있으면 + 부호로 이어줍니다
<form name="cnjform" action="../cgi/js/form-test.php3">
<input type="text" size="25" name="cnj_text" onBlur="this.value = convertSpaces(this.value);" class="cnj_input">
<input type="button" value="확인" class="cnj_input">
</form>

<!-- Script Size : 2.244 Bytes -->