lulu50
asked on
Validating an email address
Hi,
I need your help please.
I'm trying to validate an email address
Thank you,
I need your help please.
I'm trying to validate an email address
function ValidateData() {
//debugger;
var StartCreateDate = $('#FromCreatedDate').val();
var EndCreateDate = $('#ToCreatedDate').val();
var StartMigrationDate = $('#FromMigrationDate').val();
var EndMigrationDate = $('#ToMigrationDate').val();
var SendToEmail = $('#SendEmailTo').val();
if ((StartCreateDate != null && EndCreateDate != null) && (StartCreateDate > EndCreateDate)) {
alert("From create date must be greater than to create date")
return false;
}
if ((StartMigrationDate != null && EndMigrationDate != null) && (StartMigrationDate > EndMigrationDate)) {
alert("From migration date must be greater than to migration date")
return false;
}
if (SendToEmail "doesn't have the correct format") //Here I want to validate my email address $('#SendEmailTo').val();
{
alert("Email format is incorrect")
return false;
}
return true;
}
Thank you,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
EXPERT CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the same error I try the other one
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
Source Error:
Line 124: var EndMigrationDate = $('#ToMigrationDate').val( );
Line 125: var SendToEmail = $('#SendEmailTo').val();
Line 126: var ValidEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_ `{|}~-]+@[ a-zA-Z0-9] (?:[a-zA-Z 0-9-]{0,61 }[a-zA-Z0- 9])?(?:\.[ a-zA-Z0-9] (?:[a-zA-Z 0-9-]{0,61 }[a-zA-Z0- 9])?)*$/;
Line 127:
Line 128:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
Source Error:
Line 124: var EndMigrationDate = $('#ToMigrationDate').val(
Line 125: var SendToEmail = $('#SendEmailTo').val();
Line 126: var ValidEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_
Line 127:
Line 128:
Not sure your environment, but in a couple of bare bones tests here the part I suggested seems to work...
https://jsfiddle.net/wbtzo45r/
http://tpcg.io/UPQcnK3G
»bp
https://jsfiddle.net/wbtzo45r/
http://tpcg.io/UPQcnK3G
»bp
I miss the slahes :
function emailHaveCorrectFormat(email) {
var filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
return filter.test(email.value);
}
ASKER
I still get the same error
it's looking for this ( )
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
Source Error:
Line 110:
Line 111:function emailHaveCorrectFormat(ema il) {
Line 112: var filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^ _`{|}~-]+@ [a-zA-Z0-9 ](?:[a-zA- Z0-9-]{0,6 1}[a-zA-Z0 -9])?(?:\. [a-zA-Z0-9 ](?:[a-zA- Z0-9-]{0,6 1}[a-zA-Z0 -9])?)*$/;
Line 113: return filter.test(email.value);
Line 114:}
Source File: /Views/CareAdvanceBusiness Rules/Mana gement.csh tml Line: 112
it's looking for this ( )
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
Source Error:
Line 110:
Line 111:function emailHaveCorrectFormat(ema
Line 112: var filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^
Line 113: return filter.test(email.value);
Line 114:}
Source File: /Views/CareAdvanceBusiness
it's an issue with your code editor not with the code itself or maybe another block of your page
ASKER
yes I agree Thank you so much
ASKER
Thank you
you welcome
ASKER
I'm getting this error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
Source Error:
Line 110:
Line 111: function emailHaveCorrectFormat(ema
Line 112: var filter = ^[a-zA-Z0-9.!#$%&'*+\/=?^_
Line 113: return filter.test(email.value);
Line 114: }