come faccio a creare una funzione che controlli che in un campo sia stata inserita una data?
non so se ciò che dico è molto chiaro, ma ci provo lo stesso!
grazie!![]()
come faccio a creare una funzione che controlli che in un campo sia stata inserita una data?
non so se ciò che dico è molto chiaro, ma ci provo lo stesso!
grazie!![]()
Prova:
Formato gg/mm/aaaa o gg-mm-aaacodice:<html> <head> <title>...</title> <script> function s(x){ if(/^[0-9]{2}(\-|\/)[0-9]{2}(\-|\/)[0-9]{4}$/.test(x)) { x = x.replace("/","-"); x = x.replace("/","-"); x = x.split("-"); if((x[0]>31)|(x[1]>12))alert("Formato data errato") } else alert("Formato data errato") } </script> </head> <body> <input type="text" onBlur="s(this.value)"> </body> </html>
Only the good die young
all the evil seem to live forever
:metallica