| Index
» Projects
» phpMyEdit
» Forum
» problem using regular expression |
 |
tsrwebmanager
Joined: 26 Apr 2008
Posts: 2
Posted: 2008-04-28 11:58
Back to top
Reply with quote
|
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
| Code: |
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
| Code: |
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
|
|
Post new topic
Reply to topic
|
|
|
|