In your original code, you had a bogus { before your first if:
Code:
var email = document.forms["client_add"]["email"].value;
{ /* <<<=== BOGUS! */
if (fName==null || fName==="")
There are other things wrong in that code:
(1) you apparently created your <form> tag as
<form name="client_add" ...>
Named forms are obsolete. You should give your form an id, instead.
And then you can do:
Code:
function validateForm()
{
var form = document.getElementById("client_add");
var fName = form.first_name.value;
var password = form.password.value;
var confirmPassword = form.confirm_password.value;
var phoneNumber = form.phone_number.value;
var email = form.email.value;
...
**********
(2) A form field value can *NEVER* be null. Never. If the field doesn't exist, then the field itself will be null. But the
.value property is never null. It will always be a string. It might be a blank string ("") but it won't be null.
(3) Validation that only checks to see if a field is != "" is not worth bothering with.
A user can enter a SINGLE SPACE for the field value and your code would happily accept it. If your validation is that weak, why bother with it?