The validation of Javascript with the onsubmit function does not work in IE8 and IE7

advertisements

I have a simple html form for which I want to validate the 2 inputs. The validation works fine in Chrome, Firefox, IE9 and IE10. i.e. If I dont enter any values for plat and plng, the submit isnt executed in these browsers.

However in IE8 and IE7, the validation fails and I end up submitting the form and execute /php/search.php.

I am sourcing Jquery 1.8.3 on the page.

<form class="form-wrapper cf" id="search-form-primary" action="/php/search.php" method="post" onsubmit="return validateForm();">
    <input id="plat" name="plat" value="" type="text" >
    <input id="plng" name="plng" value="" type="text" >
    <button id="search" type="submit">Search</button>
</form>

<script type="text/javascript">
    function validateForm() {
        var latt= $('#plat').val();
        var lngi = $('#plng').val();
        if ((latt == "") || (lngi == "") || (latt == null) || (lngi == null))
            return false;
        else
            return true;
        }
</script>


Please add javascript: in onsubmit for mainly IE browsers

for example

onsubmit="javascript:return validateForm();"