Safari is not acknowledging the “required” attribute. How to fix it?

前端 未结 3 2017
不知归路
不知归路 2020-12-16 14:51
相关标签:
3条回答
  • 2020-12-16 15:14

    Currently, Safari doesn’t yet emit any error messages for required values in form fields that the user has not provided (nor for invalid values the user has put into form fields). But you can enable it by using hacks or a polyfill. See HTML5 Form Validation Fallback (without a library) for a lightweight hack that enables it, and see h5Validate for a jQuery-based polyfill plugin.

    0 讨论(0)
  • 2020-12-16 15:15

    At this time, Safari doesn't support the "required" input attribute. http://caniuse.com/#search=required

    To use the 'required' attribute on Safari, You can use 'webshim'

    1 - Download webshim

    2 - Put this code :

    <head>
        <script src="js/jquery.js"></script>
    
        <script src="js-webshim/minified/polyfiller.js"></script> 
    
        <script> 
            webshim.activeLang('en');
            webshims.polyfill('forms');
            webshims.cfg.no$Switch = true;
        </script>
    </head>
    
    0 讨论(0)
  • 2020-12-16 15:20

    The required attribute should be available in Safari 10.1 and newer.

    0 讨论(0)
提交回复
热议问题