Salve,
ho scritto il seguente form HTML
codice:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<fieldset>
<legend>Dati</legend>
<label>Nome:</label><input type="text" name="nome" size="50" maxlength="50" /><br><br>
<label>Cognome:</label><input type="text" name="cognome" size="50" maxlength="50" /><br><br>
<label>Data di nascita:</label><input type="date" name="ddn" /><br><br> CAP:
<input type="text" name="cap" size="5" maxlength="5" pattern="(0|1||2|3|4|5|6|7|8|9)(0|1||2|3|4|5|6|7|8|9)(0|1||2|3|4|5|6|7|8|9)(0|1||2|3|4|5|6|7|8|9)(0|1||2|3|4|5|6|7|8|9)" />
<button type="submit">Enter</button>
<button type="reset">Cancel</button>
</fieldset>
</body>
</html>
Adesso vorrei validare i vari campi presenti nel form. In particolare, per il campo cap (codice di avviamento postale) tento di utilizzare una espressione regolare inserendo quest'ultima nell'attributo pattern. Purtroppo però ho verificato che non funziona e l'utente può inserire quindi anche delle lettere.
Non capisco il perché.
Qualcuno gentilmente può aiutarmi?
Thanks
Tulipan