olton / Metro-UI-CSS

Impressive component library for expressive web development! Build responsive projects on the web with the first front-end component library in Metro Style. And now there are even more opportunities every day!
http://metroui.org.ua/
MIT License
7k stars 1.97k forks source link

Adding functions to validate a form #1090

Closed Sikito closed 6 years ago

Sikito commented 6 years ago

I'm making a form where i want to check if the date choosen isn't a Sunday and isn't lesser than the current date.

<input name="date" data-validate="required" type="date" data-role="calendarpicker" data-locale="fr-FR" data-format="%Y-%m-%d" placeholder="Choisissez une date" />

I just want to know how and if it's possible to write something like data-validate="myfunction()" to make the form behave like the predefined functions

olton commented 6 years ago

wait for 4.2.3

--- html
<input type="text" data-validate="custom=myValidateFuncName">

--- javascript
function myValidateFuncName(val){
  val = parseInt(val);
  return Metro.utils.isInt(val) && (val > 3 && val < 9);
}
Sikito commented 6 years ago

I will wait, thanks