English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have googled, forummed, read the manual and I am still unable to accomplish or properly understand form validation.

Would anybody like to correspond and help me work this out.

2007-11-24 04:31:56 · 2 answers · asked by Taffd 3 in Computers & Internet Programming & Design

To answer Colinc,
I use dreamweaver, php4 and mysql. My site depends on user input, mostly text.
I want to validate the input as text plus punctuation only, input to database or redirect to original form page with error messages.
I am having trouble making even the simplest validation using preg_match and simple regex to perform as expected, even when using a form and error page to practise.

2007-11-24 05:55:14 · update #1

2 answers

For simple validation, you do not necessarily need regular expressions. Try this:

function isValid ($string) {
$allowed = 'string containing all allowed characters';
$n = strlen ($string);
for ($i = 0; $i < $n; $i++) {
if (strpos ($allowed, $string{$i}) === false) {
return false;
} else {
continue;
}
}
return true;
}

2007-11-26 11:11:03 · answer #1 · answered by NC 7 · 1 0

Depends what you mean by form validation. What are you trying to validate?

2007-11-24 13:19:05 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers