• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTML5 field validation

 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic