john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

javascript validation email checkbox

javascript-validation-email-checkbox

function validateMyForm()
{


if (document.getElementById('txCompany').value == '')
    {
        alert('Please type in the name of your Company');
        document.getElementById('txCompany').focus();
        return false;
    }
    if (document.getElementById('txEMail').value == '')
    {
        alert('Please fill in your Email address');
        document.getElementById('txEMail').focus();
        return false;
    }
    else
    {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        var address = document.getElementById('txEMail').value;

        if(reg.test(address) == false)
        {
            alert('Invalid Email Address');
            document.getElementById('txEMail').focus();
            return false;
        }
    }


    var chks = document.getElementsByName('chbDisplayTechnologyOfInterest[]');
    var checkCount = 0;
    for (var i = 0; i < chks.length; i++)
    {
        if (chks[i].checked)
        {
            checkCount++;
        }
    }
    if (checkCount < 1)
    {
        alert("Please select at least one Technology of interest.");
        document.getElementById('chbDisplayTechnologyOfInterest').focus();
        return false;
    }


return true;

}
</script>

  • « html form replace button with image and label for
  • javascript validate radio button »

Published

Feb 6, 2010

Category

javascript

~77 words

Tags

  • checkbox 1
  • email 14
  • javascript 43
  • validation 8