如何使用javascript自动更正名称 [英] how to correct name automatically using javascript

查看:75
本文介绍了如何使用javascript自动更正名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框和标签



i希望从给定的文本框中删除特定文本以获得$


当我输入文字aabbcc

i想要删除aa并在警告中显示为bbcc





< asp:TextBox ID =txtnamerunat =server>

< asp:Label ID =Label1runat =serverText =>




< asp:Button ID =btnClickrunat =serverText =ClickOnClientClick =Click(); />









功能点击(){

alert(1);

var str = document.getElementById('txtname')。value;

alert(str);

document.getElementById('Label1')。value = str;

alert(document.getElementById('Label1')。value);



}

i have a text box and label

i want to remove a particular text from given text box for ex

when i enter text aabbcc
i want to remove aa and show in alert as bbcc


<asp:TextBox ID="txtname" runat="server">
<asp:Label ID="Label1" runat="server" Text="">


<asp:Button ID="btnClick" runat="server" Text="Click" OnClientClick="Click();" />




function Click() {
alert("1");
var str = document.getElementById('txtname').value;
alert(str);
document.getElementById('Label1').value = str;
alert(document.getElementById('Label1').value);

}

推荐答案

在更改 TextBox 时,触发一个事件并在里面取值 TextBox 。然后调用存储过程或编写一个查询,它将单词拆分成字母并保持匹配所需列中的单词。
On change of the TextBox, fire an event and inside that take the value of TextBox. Then call a stored procedure or write a query, which will split the word into letters and keep matching the words present in the required column.


这些是编写代码所需的:

1.使用 substring() [ ^ ]方法从字符串中提取所需的字符

2.使用 ASP.NET 4.0客户端ID功能 [ ^ ]来识别asp.net中的控件
3.使用 onblur活动 [ ^ ]来激活该函数。
These are what you need to write the code:
1. Use substring()[^] method extracts the characters that you want from a string
2. Use ASP.NET 4.0 Client ID Feature[^] to identify the control in asp.net
3. Use the onblur Event[^] to fire the function.


这篇关于如何使用javascript自动更正名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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