본문 바로가기

JavaScript&Web

[Javascript] 빈칸체크하기 간단예제

<%@ page language="java" contentType="text⁄html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-⁄⁄W3C⁄⁄DTD HTML 4.01 Transitional⁄⁄EN" "http:⁄⁄www.w3.org⁄TR⁄html4⁄loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text⁄html; charset=EUC-KR">
<title>Insert title here<⁄title>
<script language="javascript">
<!--
function go(){

      
      var f = document.myform.username.value; 
      ⁄⁄ myform 이라는 form 안에 username 이라는 이름의 text 태그의 value 를 불러옴.
      if(f==""){
            alert("이름을 입력해 주세요"); 
            document.myform.username.focus(); 
            ⁄⁄ focus 가 username 이라는 text 태그로 옮겨짐.
            return;
      }
⁄⁄-->
<⁄script>
<⁄head>
<body>
<form name="myform" method="post" action="reg_ok.jsp">  ⁄⁄myform 으로 form 이름을 지정.
<input type="text" name="username" size="10">
<input type="button" value="회원가입" onclick="go();" class="btn1">
<⁄form>
<⁄body>
<⁄html>