Zip Code Validation JavaScript

<html>
<head>
<script type="text/javascript">
function validatePinCode()
{
	// Change the {6} to what ever size the pin code length is of.
    var pattern = new RegExp("^[0-9]{6}$");
    if(!pattern.test(document.getElementById("txtPinCode").value))
	alert("Please enter a valid pin code.");
	else
	alert("Valid pin code.");
}
</script>
</head>
<body>
<input id="txtPinCode" type="text" />
<input id="txtPinCode" type="button" value="Submit" 
onclick="validatePinCode()"/>
</body>
</html>