Mangesh barmate

Mangesh barmate

  • NA
  • 118
  • 136.8k

How to use javascript email validation function in mvc?

Nov 23 2015 6:04 AM

Hi,

I am having below javascript function-

function validateEmail(email)
{
var regx = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/igm;
if (reg.test(email)) {
return true; }
else {
return false;
}
}

I am using this function for validating an email.

I have below MVC view code-

@Html.TextBoxFor(model => model.CustomField, new { maxlength = "51", @id = "TextBox1", onblur = ???? })

How i call this function into @Html.TextBoxFor, where it will allow to accept my input value?

Please suggest.


Answers (1)