Search code examples
htmlinputrequiredfieldvalidator

input element not working on IE


I realise that the HTML5 elements do not work on IE. ELements such as required placeholder are not working on IE. I found a javascript to make the placeholder work already but I would like to ask if is there any javascript coding to make the required attribute work as well??

Cheers!

My code:

    <input required="required" type="password" name="password" id="password" class="regfields"/>

Thanks in advance


Solution

  • add this js refrence :

    <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
    

    and try this:

    <form id="myform">
    <script type="text/javascript">
        jQuery.validator.setDefaults({
            debug: true,
            success: "valid"
        }); ;
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#myform").validate({
                rules: {
                    field: "required"
                }
            });
        });
    </script>
    <label for="field">
        Required:
    </label>
    <input class="left" id="field" name="field" />
    <br />
    <input type="submit" value="Validate!" />
    </form>