In my form i want to check for 3 things.
1. word count limit
2. required fields
3. agree term
below are the 3 function script i did , it work if i call 1 of the function, but if i call 3 function together it not work.
please help me on this, thanks
<form name="agreeform" onSubmit="return defaultagree(this); checkwords(this); checkrequired(this)">
CODE
<script>
<!--
function checkwords(cur){
var maxwords=10
if (document.images){
var temp=cur.words.value.split(" ")
if (temp.length>maxwords){
alert("Please restrain your input to 10 or less words!")
return false
}
}
}
//-->
</script>
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
return true
}
</script>
<script>
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
</script>