c# - Client side form validation in mvc4 -


can validate email , password using jquery.

i using following codes validation . not working

 @using (html.beginform(new { @class = "emlfrm" }))  {  @html.validationsummary(true)        <p>@html.label("email")         @html.textboxfor(model => model.mem_email, new { @class = "eml" })         <label id="error" style="padding:0;color:red;font-size:12px; width:100%;"></label>       </p>      <p style="padding:0 20px;">         @html.label("password")         @html.editorfor(model => model.mem_pwd)       </p>     <p style="margin-left:27%;">         <input type="submit" value="submit" />     </p>      }   $(function () { $(window).on('load', function () {     $(".emlfrm").on("submit", function () {         //email validation         var x = $(this).find(".eml").eq(0).val();         var atpos = x.indexof("@");         var dotpos = x.lastindexof(".");         if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {             $("#error").html("not valid email address.");         return false;         }     }); }); 

this not show error message.

do have following in web.config file:

<add key="clientvalidationenabled" value="true" /> 

if not there add - should added <appsettings> section.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -