从文本框中获取文本 [英] Get text from textbox

查看:65
本文介绍了从文本框中获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从文本框中检索值以进行验证.

但是,当我尝试从文本框中获取值时,会得到未定义的值.

我的按钮代码是:

I want to retrieve value from text boxes to do validation.

However when I am trying to get value from a text box I get undefined value.

my code for button is :

<asp:LinkButton ID="lbLogin" runat="server" OnClientClick="Validation()" OnClick="btnLogin_Click" ValidationGroup="Submit">Login</asp:LinkButton>




文本框是:




text box is:

<asp:TextBox ID="tbPassword" runat="server" TextMode="Password" Width="124px"
CssClass="textbox"></asp:TextBox>


功能是:


And function is :

function Validation() {
           var password = $("#tbPassword").val();
           alert(password);
       }




警报始终显示未定义".




Alert always show "undefined". Is there anything wrong in my function?

推荐答案

(#tbPassword").val(); 警报(密码); }
("#tbPassword").val(); alert(password); }




警报始终显示未定义".我的函数有什么问题吗?




Alert always show "undefined". Is there anything wrong in my function?


嘿,请尝试这个

如果您使用母版页,那么

Hey Try This

if u used master page then

function Validation() {
                  
           var pwd = document.getElementById('cntPlcHolder_tbPassword').value;
           alert(pwd);
       }


其他明智的


other wise

<pre lang="cs">function Validation() {

           var pwd = document.getElementById('tbPassword').value;
           alert(pwd);
       }</pre>



祝你好运



best luck


尝试一下

try this

//jquery


这篇关于从文本框中获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆