I am a beginner and I have written a code for validating the form as:
function validateForm(){ var x=document.forms[\"myForm\"][\"fname\"].value; if (x==null ||
replace your input element's code by following
i guess thats what you are looking for