|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Mar 2005
Messaggi: 111
|
RegularExpressions in Javascript
ciao a tutti,
devo fare il matching in javascript di una stringa che può contenere solo lettere e spazi; in alternativa al controllo carattere per carattere ho provato a usare le espressioni regolari, ma senza successo; ho usato Codice:
var expr= new RegExp("/[^a-zA-Z\s]+/");
if (expr.test(str))
{
alert("Errore.");
return false;
}
qualcuno riesce a darmi una mano. Grazie mille.
__________________
How happy is the blameless vestal's lot! The world forgetting, by the world forgot. Eternal sunshine of the spotless mind! (Alexander Pope) ----Hale |
|
|
|
|
|
#2 | |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Codice:
if (str.match (/^[a-zA-Z\s]+$/))
{
...
}
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Mar 2005
Messaggi: 111
|
Grazie mille, mi sei stato di grandissimo aiuto. Probabilmente era la mancanza di ^ e $ che dava dei problemi.
ciao.
__________________
How happy is the blameless vestal's lot! The world forgetting, by the world forgot. Eternal sunshine of the spotless mind! (Alexander Pope) ----Hale |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:44.



















