It has to be a minor issue but I just can’t find it. Maybe one of you can help me here.
Javascript
function white_space(field)
{
field.value = field.value.replace(/^\s+/, "");
}
function validate(){
var formname=document.reg_form;
var fname=formname.fname.value;
var mess="";
var uname=formname.prodName.value;
if(uname==""){
mess= mess+"User Name cannot be blank\n";
}
var pass=formname.prodPrice.value;
if(pass==""){
mess= mess+"Password cannot be blank\n";
}
if(mess){
alert(mess);
return false;
}
}
HTML FORM
<form class="form-signin" action="#" onSubmit="return validate();" name="reg_form">
<h2 class="form-signin-heading">Sign-In</h2>
<input type="text" class="input-block-level" name="prodName" placeholder="Email address" onKeyPress="white_space(this)">
<input type="password" class="input-block-level" name="prodPrice" placeholder="Password" onKeyPress="white_space(this)">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
Error

Browser doesn’t show an empty string error.
in your case this line
throw error while execution validate function, as there is no element with
fnameinto the form, comment it and you are finehttp://jsbin.com/oxawil/1