• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HTML5 field validation

 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • 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 Firefox Browser Fedora
  • 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: 218
VI Editor Ruby Ubuntu
  • 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 Firefox Browser Fedora
  • 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.
 
Die Fledermaus does not fear such a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic