JuneDeng


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

表单校验之novalidate

发表于 2018-06-06 | 分类于 技术

用django写后台项目,表单使用form,在模板中这样渲染:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<form method="post" novalidate action="{% url 'users:login' %}">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="error-msg">
{% for error in form.non_field_errors %} {{ error }} {% endfor %}
</div>
{% endif %}
{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}">
<label>{{field.label}}</label>
{{ field }} {% if field.help_text %}
<span class="help-block">{{ field.help_text|safe }}</span>
{% endif %} {% for error in field.errors %}
<span class="error-msg">{{ error }}</span>
{% endfor %}
</div>
{% endfor %}
<div class="form-group">
<button type="submit" class="btn-submit">登录</button>
</div>
</form>

因为账号和密码等等字段都是必填的,有required属性,自带的提示根据浏览器和语言都会不一样。这不是我想要的效果。

作为一个前端工程师,在后端小朋友的提示下,给表单加了novalidate属性,来去除默认的提示。然后再自己写error-msg样式。有点忧伤
参考阅读:

  • [表单数据校验](https://developer.mozilla.org/zh-CN/docs/Learn/HTML/Forms/Data_form_validation )
  • novalidate
  • 表单新属性

在网站中使用微软雅黑字体是否构成侵权

发表于 2018-06-04 | 分类于 技术

早起搬砖,就看到前端群有个小伙伴在说公司被发了侵权警告书了,因为他们用了微软雅黑的字体。
我们公司的设计师也很喜欢用微软雅黑,回想自己做的项目,基本都是用这个字体,当即吓了一跳。
立刻开始Google。
找到了这篇文章,做了详细的描述。
总结如下:

  • 我们可以将字体用在个人或商业的工作站上,但不允许将字体安装在服务器上,不能使用 css 的 @font-face 调用,字体文件不能被修改或者作为软件的一部分进行分发。这些都需要获得相应授权。在商业网站的图片上使用微软雅黑字体属于侵权行为。
  • 我们在css中使用 {font-family:microsoft yahei} 是在合法的使用范围内。

通过css3的 @font-face 引入web字体是有风险的,尤其是对于商业性的网站。
对于个人站点,想使用合法授权的web字体,可以访问:

  • http://webfonts.fonts.com/
  • https://typekit.com/
  • http://www.google.com/webfonts

不必担心在css中使用字体名称,因为它仅仅调用了终端用户自身系统中存在的字体,不需要任何额外的许可。

you actually do not need a license to include the font name in your CSS, because it is only calling on the system font already existing in the end user’s computer, which does not need any extra license.

我自己的想法:平时设计师给的图文结合的设计稿,最好切图的时候只切css实现不了的图片,文字自己用html、css来写。这样既方便用户复制粘贴,又不会用侵权的风险。

1…678…32
June Deng

June Deng

make the world a better place

63 日志
2 分类
24 标签
GitHub
© 2018 June Deng
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4