使用javascript和php进行表单验证

I was creating a form with validation

here is the js file is : http://pastebin.com/Ahy4dbsS

php file : http://pastebin.com/5B1hMK49

the problem is when I submit the form without clicking on any text boxes, no validation happens, so i changed the js file so that the first text box will be focused on page load. but when that text box is validated (ie. click outside of the form) and form can be submitted without validation. how can i validate all the text boxes on page load?

Better use a variable ex: var flag=0; and for every condition increment the flag as flag=flag+1; do this in all conditions finally make a condition:

if(flag>0){return false}else{return true}