RAN
RAN

Reputation: 1453

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.

Upvotes: 0

Views: 223

Answers (3)

skub
skub

Reputation: 2306

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

Upvotes: 1

gilly3
gilly3

Reputation: 91527

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

Upvotes: 3

Roy Lee
Roy Lee

Reputation: 10862

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.

Upvotes: 1

Related Questions