#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    21
    Rep Power
    0

    error with document.getElementById(....) is null


    I have the the code validation and it worked fine on IE but not in Chrome or FF. I got an error :
    document.getElementById(....) is null

    Done anyone know why?

    thanks


    <script type="text/javascript">
    function validateForm(oForm) {

    var numChecked = 0;
    var flag = document.getElementById('other').checked;
    for (var idx=0; idx<oForm.cat_int_fk.length; idx++) {
    if (oForm.cat_int_fk[idx].checked == true) {
    numChecked++;
    break;
    }
    }

    //}
    if ((flag !== true) && (numChecked == 0)) { alert('Please check at least one checkbox needs to be checked.'); return false; }




    var str = document.getElementById('other_text').value;
    var flag = document.getElementById('other').checked;
    if ((flag == true) && (str == '')) { alert('Other name must be entered.'); return false; }



    var str = document.getElementById('other_text').value;
    var flag = document.getElementById('other').checked;
    if ((flag !== true) && (str !== '')) { alert('Other name must be checked.'); return false; }


    return true;

    }


    </script>



    <form action="action.cfm" method="post" name="form" id="form" onsubmit="return validateForm(this);">
    .......
    </form>
    Last edited by knkt; June 3rd, 2013 at 10:25 AM. Reason: add more code

IMN logo majestic logo threadwatch logo seochat tools logo