| Index
» Projekty
» phpMyEdit
» Fórum
» problem using regular expression |
 |
tsrwebmanager
Založený: 26.04.2008
Príspevky: 2
Zaslal: 2008-04-28 11:58
Návrat hore
Odpovedať s citátom
|
I have found that, when using a regular expression for field validation, if the regexp is reasonably simple there is no problem, but with a complex regex the process doesn't always work.
Does any one have a regex to validat email addresses that works?
May I suggest a revision to the code (the following is for validating a numeric field, it works as is - but I use it as an example) so that the JSCript generated uses a variable for the regex. i.e for a simple regex of
instead of generating
| Kód: |
if (PME_js_trim(theForm.PME_data_mship_no.value) == "" || !(/^[0-9]*$/.test(PME_js_trim(theForm.PME_data_mship_no.value)))) {
alert("Membership number MUST be unique, and contain only digits 0-9.");
theForm.PME_data_mship_no.focus();
return false;
}
|
you generate
| Kód: |
PME_data_mship_no_regex='/^[0-9]*$/';
if (PME_js_trim(theForm.PME_data_mship_no.value) == "" || !(PME_data_mship_no_regex.test(PME_js_trim(theForm.PME_data_mship_no.value)))) {
alert("Membership number MUST be unique, and contain only digits 0-9.");
theForm.PME_data_mship_no.focus();
return false;
}
|
This would better facilitate the use of complex reg expressions
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|