Validation: What is the method used in this example?

Asked

Viewed 37 times

1

I’m studying ways to validate forms. I’ve tried it with Javascript, HTML5 features and some other methods, but they all have something in common.

Always have to call a function in onclick(), onblur() and the like.

I wouldn’t want to do that, since removing this from the code, all validation would be circumvented. So I thought of ways to do some sort of validation that doesn’t have to be called the click of a boot or something. This example of the gmail site made me curious:

inserir a descrição da imagem aqui

Note that HTML5’s Patterns or required are not used or no Javascript function call via clicks. Does anyone have any idea how this validation was done?

  • This google front-end validation can also be circumvented :)

  • 2

    If you want to make an effective validation, you should do it in the back end

  • 2

    In fact, there are many ways to validate the client. But there is a golden rule: never rely on customer validation. It can be bypassed regardless of the implementation (HTML5 validation or javascript). Always validate also on the server the received data. HTML5 validation is something very simple, and the behavior depends on the browser (ie, you can not customize much). Javascript validation is something more advanced (allows higher.

  • The events you refer to (onclick, onchange) may be next to the input (inline), or may have been declared somewhere else in the code (as is probably the case for gmail), through a addEventListener, for example, and the decision where to place depends on the organization of your code and your project. In fact, putting these inline events is a little recommended practice, because of the principles of separation of concepts (html is html, style is style, script is script). Broadly speaking, that’s it, but surely that’s just one Overview.

  • 1

    http://answall.com/q/13298/101

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.