Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Email Problem

Asked Modified Viewed 765 times
A
afoster
A
  • Senior Member, joined since
  • Contributed 725 posts on the community forums.
  • Started 128 threads in the forums
  • Started this discussions
asked
Senior Member

I have a registration form (not php-fusion related) that requires an email address. The problem I am having is that if the email address contains a period (.), there is an error that states it is not a valid address and the form is not submitted. The code in the validate.js file that is part of the registration form is as follows:


function isEmail(field, ErrorMsg) {
   var strMsg = "";
   var chAt = '@';
   var chDot = '.';
   var strEmailAddr = trim(field.value);
    if (strEmailAddr.length == 0) return true;
    if (strEmailAddr.indexOf(" ") == -1)
    {
    var iFirstAtPos = strEmailAddr.indexOf(chAt);
    var iLastAtPos = strEmailAddr.lastIndexOf(chAt);
    if (iFirstAtPos > 0 && iFirstAtPos < (strEmailAddr.length - 1) &&iFirstAtPos == iLastAtPos) {
       // look for '.' there must be at least one char between '@' and '.'
       var iDotPos = strEmailAddr.indexOf(chDot, iFirstAtPos + 1);
       if (iDotPos > (iFirstAtPos + 1) && iDotPos < (strEmailAddr.length -1)) return true;
    }
    }
    alert(ErrorMsg);
    field.focus();
    return false;
}


The code that processes the registration form also has the following code:

echo "<center><br><br><span style='font-size:16px; color:#840000;'><b>".$emailError."<a href='javascript:history.go(-1)'>Go Back and Redo!</a></b></span></center>\n";
exit;
} else if(!preg_match("/^[\w-]+[@]+[a-z]+\.+[a-z]*$/", $_POST['email'])) {
   //} else if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
      $emailError = "Invalid email format. ";
      $email ="";
echo "<center><br><br><span style='font-size:16px; color:#840000;'><b>".$emailError."<a href='javascript:history.go(-1)'>Go Back and Redo!</a></b></span></center>\n";
exit;


What code needs to be adjusted and in which file does it need to be adjusted to fix this problem? Thanks in advance.
0 replies

1 post

C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

$re = '/[\w-.]+[@]+[a-z]+\.+[a-z]*/m';
$str = 'gmail.gmail.com@gmail.com
';

preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);

// Print the entire match result
var_dump($matches);
1 reply

Category Forum

General Discussion

Labels

None yet

Statistics

  • Views 0 views
  • Posts 1 post
  • Votes 0 votes
  • Topic users 2 members

2 participants

A
A
  • Senior Member, joined since
  • Contributed 725 posts on the community forums.
  • Started 128 threads in the forums
  • Started this discussions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet