在 asp.net 中使用 javascript 显示标题属性消息

Displaying Title attribute message using javascript in asp.net

本文关键字:显示 标题 属性 消息 javascript asp net      更新时间:2023-09-26

我正在制作一个小的注册表,其中我有几个输入字段。 对于验证过程,我尝试添加一个 javascript 函数,该函数可以帮助我在一个文本框中使用 onchange 概念验证输入数据,同时按 TAB 移动到下一个文本框。目的是一旦我输入错误的数据并按 TAB,标题属性中的消息就会出现。但到目前为止,我没有成功。 javascript 函数是客户端的。以下是代码片段。 有人可以帮我吗?

function myFunction(title) {
     var at = title.value;
     alert(at);
}
<input type="text" name="Firstname"  ValidationExpression=[a-zA-Z] title="Firstname not correct" onchange="myFunction(this.title)">
<input type="text" name="telno" ValidationExpression=[0-9]{7} title="Tel num not correct" onchange="myFunction(this.title)">
<input type="text" name="Address" ValidationExpression=[a-zA-Z0-9] title="Address not correct"  onchange="myFunction(this.title)">

提前感谢您的回复。

onchange属性已经将title属性传递myFunction(this.title),这是正确的语法。

function myFunction(title) {
     var at = title;
     alert(at);
}
<input type="text" name="Firstname"  ValidationExpression=[a-zA-Z] title="Firstname not correct" onchange="myFunction(this.title)">
<input type="text" name="telno" ValidationExpression=[0-9]{7} title="Tel num not correct" onchange="myFunction(this.title)">
<input type="text" name="Address" ValidationExpression=[a-zA-Z0-9] title="Address not correct"  onchange="myFunction(this.title)">