javascript - Tab Validation for Required Field in MVC4 Razor -
i want implement tab validation in mvc.i have 2 textbox password , confirm password , confirm password should same password .till have done compare validation , validating getting validation message when form submitting. want on tab means after entering confirm password on tab if not same password want validation message approach want use either jquery or javascript.can please me this.i sharing code.
view
@using (html.beginform("save", "saveinfo", formmethod.post)) { @html.validationsummary(true) <div style="color:red; text-align:center" > <fieldset> <legend>validation summary</legend> @html.validationmessagefor(m => m.password) <br /> @html.validationmessagefor(m=>m.confirmpassword) </fieldset> </div> <br /> <br /> <div> <table border="1" style= "width:500px"> <tr> <td> @html.labelfor(m=>m.password) </td> <td> @html.passwordfor(m => m.password, new { style="width:300px"}) </td> </tr> <tr> <td> @html.labelfor(m=>m.confirmpassword) </td> <td> @html.passwordfor(m => m.confirmpassword, new { style="width:300px"}) </td> </tr> </table> <input type="submit" value="save" /> </div> }
model
using system; using system.collections.generic; using system.linq; using system.web; using system.data; using system.data.sqlclient; using system.configuration; using system.componentmodel; using system.componentmodel.dataannotations; namespace employee_mgmt_system.models { public class employeeregistration { [required(errormessage = "password cannot kept blank")] [datatype(datatype.password)] [display(name = "password")] public string password { get; set; } [required(errormessage = "confirm password cannot kept blank")] [datatype(datatype.password)] [display(name = "confirm password")] [compare("password", errormessage = "password , confirm password not matching")] public string confirmpassword { get; set; } } }
try it:-
i using of jquery may you.
jquery('.validatedform').validate({ rules : { password : { minlength : 5 }, password_confirm : { minlength : 5, equalto : "#password" } } });
i think there should it.
Comments
Post a Comment