English 中文(简体)
如何将标签文本改为javascript功能?
原标题:How to change the label text in javascript function?

i want to validate login page using java script function. i take one label button for displaying message and two text box for username and password and one button for "Login" .

当用户在未输入用户名和密码的情况下点击“Login”纽顿时,电文将显示在标签控制中。 因此,如何检查javascript功能中的文字箱值以及如何改变胶卷的价值。 我在奥克顿称这一职能。 我将这一职能放在布顿· OnClientClick活动上,但这不是什么工作。

问题回答

With javascript

简单的例子

var lblElement = document.getElementById("yourlabelsid");

lblElement.innerHtml("Your new updated text in the label");

But try to use a javascript libray like jquery, it has a lot of benefits and ease. Generically on jquery, to change the markup of any element, we use

$("#theselector").html("the new markup inside the markup");

In case input elements, we use .val(); $("#mytextbox").val("the value in the textbox");


根据您的描述,你想把字句改为简单的例子。

标签

<label id="lbl_name">Name:</label>

Use

$("#lbl_name").html("the updated html"); 

页: 1

更好地使用作为人使用的蚊帐,需要外地验证人控制,而不是发挥特别的javascript功能来处理这一问题。

var msgLabel= document.getElementById( <%=lblMessage.ClientID %> );
msgLabel.innerHTML = "Your message here";

<script language="javascript">

    function check() {
     var a = document.getElementById( <%=label.ClientID%> );
     var b = document.getElementById( <%=textbox.ClientID%> ).Value;
     var c = document.getElementById( <%=textbxpassword.ClientID%> ).Value;

        if (b  == "" &&  c == "") 
        {
             a.innerHTML = "your text here";
             alert(a.innerHTML);
        }
     }

</script>




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签