asp.net mvc - MVC read value from textboxfor with jquery -


i think it´s pretty simple, don´t it. want read value input control jquery.

i have line:

@html.textboxfor(m => m.email, new { placeholder = "email" }) 

if try read value line, empty string

$("#email").val() 

if try this, works

$("#email").keyup(function () {         alert(this.value);     }); 

i hope can me. thanks

edit: html

<input name="email" id="email" type="text" placeholder="email" data-val-required="field required" data-val="true" value=""/> 

did add reference jquery?

i tested in jsfiddle , works: demo

html:

<input name="email" id="email" type="text" placeholder="email" data-val-required="field required" data-val="true" value=""/> <input type="button" id="test" value="test" /> 

javascript:

$(document).ready(function () {     $("#test").click(function () {         alert($("#email").val());     }); }); 

Comments