Web Science/Part1: Foundations of the web/Dynamic Web Content/Client side JavaScript/script

From Wikiversity
Jump to navigation Jump to search


<head><title>Registration Form</title></head>
	function validator(){
		var name = document.getElementById("userinput").value;
		if( name.length<3){
			document.getElementById("warning").innerHTML = "User name is too short. Please enter at least 3 characters.";
<h1>Registration Form for the Web Science MOOC</h1>

<form action="servlet" method="POST">
<label for="userinput">Enter User:</label>
<input name="username" id="userinput" type ="text" onchange="validator()"/><span id="warning" style="color:red"></span>
<label for="emailinput">Enter email</label>
<input name="email" id="emailinput" type ="text" />
<input name="submit" id="submitbutton" type="submit" value="register"/>