Hi,
I have this code which is not working
<script type="text/javascript" language="javascript">
<!--
function loadpage() {
document.getElementById('Loadingindic').style.top = '-500%';
}
function checkfields() {
if(name()==true){
if(email()==true){
if(message()==true){
return true;
}
}
}
return false
}
function name() {
name = document.getElementById('CF_N').value;
if ( name.length == 0 ) {
alert('Please enter your name!');
return false;
} else {
return true;
}
}
function message() {
name = document.getElementById('CF_M').value;
if ( name.length == 0 ) {
alert('Please enter a message!');
return false;
} else {
return true;
}
}
function email() {
name = document.getElementById('CF_E').value;
var validchars = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(name.match(validchars)){
return true;
}else{
alert('Please enter a valid email!');
return false;
}
}
//-->
</script>
When a form is submitted, checkfields() is run. The first time it is run it runs correctly, picking up on invalid fields but after that it just submits the form without paying attention to the validation. What is wrong?
Regards,
Sam Rudge