var submitcount=0
function checkSubmit(){
if(submitcount==0){
submitcount++
return true}
else{
alert('You have already submitted this form. Please wait...')
return false}}
function empty(str){
if(str==null || str=='')
return true
return false}
function checkempty(validform,formval,formfocus,alertmsg){
if(!validform)
return false
if(empty(formval)){
alert('Please Enter: '+alertmsg)
formfocus.focus()
return false}
return true}
function checkemail(validform,formval,formfocus,alertmsg){
var pattern=/^[\w\-]+(\.[\w\-]+)*@[\w\-]+\.([\w\-]+\.)*[a-z]{2,}$/i
if(!validform)
return false
if(empty(formval)){
alert('Please Enter: '+alertmsg)
formfocus.focus()
return false}
if(!pattern.test(formval)){
alert('Please Enter a Valid '+alertmsg)
formfocus.focus()
return false}
return true}
function checkform(form){
var validform=true
validform=checkempty(validform,form.first.value,form.first,'First Name')
validform=checkempty(validform,form.last.value,form.last,'Last Name')
validform=checkempty(validform,form.address.value,form.address,'Street Address')
validform=checkempty(validform,form.city.value,form.city,'City')
validform=checkempty(validform,form.state.value,form.state,'State')
validform=checkempty(validform,form.phone_no.value,form.phone_no,'Home Phone')
validform=checkemail(validform,form.email.value,form.email,'Email Address')
if(validform&&checkSubmit()){
return true}
return false}