• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

HTML5 field validation  RSS feed

 
Ranch Hand
Posts: 212
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm playing with the built in field validation for HTML5, how can we extend or hook up custom validation to the fields?

I haven't found how to do it yet, so end up not using it and using custom validation with jquery & bootstrap to maintain consistent way of displaying validation message.
 
author
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Listen to the invalid event and then use setCustomValidity to display a custom message with the browser UI, or display your own custom warning message:
 
Wirianto Djunaidi
Ranch Hand
Posts: 212
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry if my original question is not clear, what I meant is how can we extend the validation by providing our own rules. Not on creating custom error message. To be specific, is there a standard way to do it rather then writing custom javascript that is not consistent with how HTML5 field validation works.

I'm not a web expert, if I understand the example correctly the callback only get calls once it failed the validation process which raise the invalid event.
 
Rob Crowther
author
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Wirianto Djunaidi wrote:what I meant is how can we extend the validation by providing our own rules



OK, why don't you give some examples of the sort of rules you have in mind?

Wirianto Djunaidi wrote:if I understand the example correctly the callback only get calls once it failed the validation process which raise the invalid event.



The invalid event will be raised as part of the form submission process, or you can trigger it from a script with the checkValidity() method.
 
I can't take it! You are too smart for me! Here is the tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!