Javascript email validation denying valid emails

Project:Kaltura Community Edition (CE) - Self Hosted Online Video Platform
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Total votes:0
Description

Occurs on: install/general_info.php in alpha_1.0
Problem: emails of the form x.xxx@domain.org or xx.xxx@domain.org are not validated by the javascript.

Problem source: install/js/functions.js:

function not_valid_email(email)
{
if ((email.indexOf(".") > 2) && (email.indexOf("@") > 0)) return false;
return true;
}

Emails of the above form do not pass indexOf(".") > 2 so the function returns true (for not valid).

Comments

#1

Thanks,

will be changed to

function not_valid_email(email)
{
if ((email.indexOf(".") >= 2) && (email.indexOf("@") > 0)) return false;
return true;
}

#2

That doesn't account for x.xxx@example.org

May I suggest:

if ((email.indexOf('@') > 0) && (email.indexOf('@') < email.lastIndexOf('.'))) return false;

That should correct the problem and not allow localhost, which I'm guessing is the reason behind checking for the dot.

#3

Status:active» fixed

Accepted... :)
Will be included in next release

#4

Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.