Back to feed
Renewal·서른의 생활코딩

Sample Source 4) JavaScript Basic Document Structure: Window Object 3) Events and Event Handlers 4

NS
normalstory
cover image

This time, a login example
that takes ID and password input and connects them to the relevant site 
example///

The explanation is sparse — I should also attach a file...
Friday nights are tough..
I came up to Seoul to crash at a friend's place but they're out, so I'm posting from a nearby cafe...
Exhausted.. couldn't even wash up.. eyes are closing... :(

Sigh, either I move up to Seoul soon, or I just wait for the academy classes to end.. :(


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">




<head>


<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />


<title>Window Object Events & Event Handlers 4</title>




<meta name="Keywords" content="" />


<meta name="Description" content="" />




<script type="text/javascript">


//<![CDATA[




function id_focus(){


frm=document.loginForm; // because var is omitted, it becomes a global variable


frm.loginId.focus();


}




// blank-field validation check


function submitForm() {


var message="";




if(frm.loginID.value.length==0){


message="Please enter your ID";


objfocus=frm.login;


}else if(frm.loginPassword.value.length==0){


message="Please enter your password";


objfocus=frm.loginPassword;


}




if(message !=""){


alert(message);


objfocus.focus();


return false;


}


frm.submit();


}




//]]]]]]>


</script>


</head>




<body onload="id_focus()">


<form id="loginForm" name="loginForm" action="http://www.naver.com" method="post" onsubmit="return submitForm();" >


<p>


<label for="loginID">User ID</label>


<input type="text" name="loginID" id="loginID" value="">


</p>


<p>


<label for="loginPassword">User Password</label>


<input type="password" name="loginPassword" id="loginPassword" value="">


</p>


<p>


<input type="image" src="../images/submit.gif" alt="Log in">


<!-- onsubmit="return submitForm(); — to trigger this, it must be an image. -->


</p>


</form>


</body>




</html>

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Steadily, for the long haul, without burning out

Mar 31, 2026·9 min
Renewal

Tech-life balance

Feb 7, 2026·3 min
Renewal

Humanality, by Park Jeong-ryeol

Feb 7, 2026·11 min