0

如果浏览器禁用了 javascript,那么如何验证 html 文件?我不是在谈论'如何启用 javascript,而是如何在不使用 javascript 的情况下验证 html 表单?这个问题是面试官问的。

4

3 回答 3

3

表单验证必须始终在服务器端执行。客户端验证很棒,但可选。这肯定是面试官要找的。

于 2012-06-21T06:38:51.273 回答
1

Not sure what 'validate' means in that context (might be a good chance for you to ask a follow up question on what he/she means on html validation?)

Anyway, I am assuming that they are talking about HTML markup validation then there are online services like:

If the interviewer is talking about validation in terms of client-side validation (eg user age must contain range between X to Yetc), then you might need to validate the input on the server (eg with server side code).

于 2012-06-21T06:40:18.283 回答
1

您可以参考How to validate html for input without using javascript中的示例之一。

Javascript 是在提交数据之前在客户端验证数据的唯一方法。由于可以禁用 Javascript,因此您的服务器端代码应始终在使用之前验证任何提交的数据。

于 2012-06-21T06:38:36.447 回答