Google+

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Definire caractere permise intr-un text field
#1
Am o problema legata de definirea caracterelor permise intr-un text field dintr-un formular.

PHP Code:
if (!eregi("^[a-z0-9.-!? ]+$", $f_comentarii)) { $off .= 'Ati introdus caractere nepermise! Caracterele peermise sunt litere, cifre, semne de punctuatie.<br>'; $f_comentarii = ''; }


Practic vreau sa se poata introcuce litere, mici, mari, cifre si semne de punctuatie: punct, virgula, !, ? si semnul - (minus)
Daca ma poate ajuta cineva ar fi suberb

Multumesc.

Reply
#2
1.Utilizeaza preg_match pentru ca e mai rapid decat eregi.
2.Uite cam ce ai vrea tu :

PHP Code:
if (preg_match("/([[:alnum:]]|!|\?|\.|,)+/i", $text)) {
    echo "OK.";
} else {
    echo "Ceva nu e in regula.";
}

Users : collective term for those who use computers. Users are divided into three types : novice, intermediate and expert.
Novice users : people who are afraid that simply pressing a key might break their computer.
Intermediate users : people who don`t know how to fix their computer after they`ve just pressed a key that broke it.
Expert users : people who break other people`s computers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)