本文介绍了Safari不会确认“所需的”属性。如何解决它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form id =customerForm>
< label>
名字:
< input id =firstNamerequired />
< / label>
< label>
社会保险号码:
< input id =ssnrequired pattern =^ d {3} -d {2} -d {4} $
title =预期模式是### - ## - ####/>
< / label>
< input type =submit/>
< / form>
当我在Chrome中尝试该文档时,它接受条件并按预期显示错误。 / p>
但是,当我在Safari中尝试使用该文档时,它不会显示任何错误。 解决方案
目前,Safari不支持必需输入属性。
要在Safari上使用'required'属性,您可以使用''
- 下载webshim
2 - 把这段代码:
< 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>
<form id="customerForm">
<label>
First Name:
<input id="firstName" required />
</label>
<label>
Social Security Number:
<input id="ssn" required pattern="^d{3}-d{2}-d{4}$"
title="Expected pattern is ###-##-####" />
</label>
<input type="submit" />
</form>
When I try that document in Chrome, it accepts the conditions and shows the error, as expected.
But when I try that document in Safari, it shows no error.
解决方案
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>
这篇关于Safari不会确认“所需的”属性。如何解决它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!