简体   繁体   中英

How to validate html file without javascript?

If the browser disabled the javascript , then how to validate the html file ? I am not talking about 'how to enable javascript, but how to validate the html form without using javascript ? This question is asked by an interviewer.

Form validation must always be performed server-side. Client side validation is great, but optional. Surely this is what the interviewer was looking for.

You can refer one of the example from How to validate html for input without using javascript .

Javascript is the only way to validate the data on the client side before it is submitted. Since Javascript can be disabled, your server-side code should always validate any submitted data before using it.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM