HTML/JAVASCRIPT 2006/09/08 22:16
블로그 > 장미왕국 http://blog.naver.com/rosekingdom/60005112976 | |
<script> function check_form(theform) { if (!theform.title.value) { errorMsg("글의 제목을 입력하세요",theform.name,theform.title.name,'no','no','alert'); return false; } } function errorMsg(error_str,obj1,obj2,del,sel,ertype) { var winX = parseInt(document.body.clientWidth,10); var winY = parseInt(document.body.clientHeight,10); var scTop = parseInt(document.body.scrollTop,10); var elayer = eval(document.all.errorMessage); var Inhtml; Inhtml = "<table width=\"250\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"border: 1px solid Gray;\">"; Inhtml += "<tr>"; Inhtml += " <td width=\"250\" height=\"100\" bgcolor=\"#FFFFFF\">"; Inhtml += " <table width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#DCDCDC\" style=\"border: 1px solid Gray;\">"; Inhtml += " <tr>"; Inhtml += " <td align=\"center\">"; Inhtml += " <table width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; Inhtml += " <tr>"; Inhtml += " <td width=\"12\" height=\"32\"> </td>"; Inhtml += " <td width=\"32\" height=\"32\">"; Inhtml += " <img src=\"/img/warning.gif\" border=\"0\" align=\"absmiddle\">"; Inhtml += " </td>"; Inhtml += " <td width=\"14\" height=\"32\"> </td>"; Inhtml += " <td style=\"color:#696969;font-size: 9pt; line-height: 150%; padding : 4px 4px 4px 4px;\">"; Inhtml += error_str; Inhtml += " </td>"; Inhtml += " </tr>"; Inhtml += " </table>"; Inhtml += " </td>"; Inhtml += " </tr>"; Inhtml += " <tr>"; Inhtml += " <td height=\"35\" align=\"center\">"; if (ertype=="alert") { Inhtml += " <img src=\"/img/icon_ok.gif\" onclick=\"document.all.errorMessage.style.display='none';errorFocus('"+obj1+"','"+obj2+"','"+del+"','"+sel+"');\" style=\"cursor:hand\">"; } else if (ertype=="confirm") { Inhtml += " <img src=\"/img/icon_ok.gif\" onclick=\"document.all.errorMessage.style.display='none';document."+obj1+".submit();\" style=\"cursor:hand\">"; Inhtml += " <img src=\"/img/icon_cancel.gif\" onclick=\"document.all.errorMessage.style.display='none';errorFocus('"+obj1+"','"+obj2+"','"+del+"','"+sel+"');\" style=\"cursor:hand\">"; } Inhtml += " </td>"; Inhtml += " </tr>"; Inhtml += " </table>"; Inhtml += " </td>"; Inhtml += "</tr>"; Inhtml += "</table>"; elayer.innerHTML = Inhtml; elayer.style.posLeft = (winX-250)/2; elayer.style.posTop = scTop + ((winY-100)/2); elayer.style.display = "block"; } function errorFocus(obj1,obj2,del,sel){ var temp = eval("document."+obj1+"."+obj2); if (del=="yes") { temp.value=""; } if (sel=="yes") { temp.select(); } temp.focus(); } function IsNumber(str) { if (str.search(/[^0-9]/g)==-1) return true; else return false; } <script> ---------------------------------------------------- <div id="errorMessage" style="display:none;position:absolute;"></div> <--에러메세지 띄우는 레이어 <form method=post action="ok.php" name=boardin enctype='multipart/form-data' onsubmit="return check_form(document.boardin)"> <input type="text" name="title" size="40"> <input type="submit" value="입력"> </form> |
이 글에는 트랙백을 보낼 수 없습니다
0