Replace all spaces with underscores while textbox value using JQuery
Many times we want to remove with some values so in
this article we are removing the space values with underscore while typing. We
can get this thing with below methods:-
Source Code:-
<%@
Page Language="C#" AutoEventWireup="true" CodeFile="replace_all_spaces.aspx.cs"
Inherits="replace_all_spaces" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=txtvalue.ClientID%>').keyup(function () {
this.value
= this.value.replace(/ /g, "_");
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset style="height: 40px; width: 350px;">
<legend>Replace
all spaces with undersore</legend>
<asp:TextBox ID="txtvalue" runat="server" Width="350px"></asp:TextBox>
</fieldset>
</div>
</form>
</body>
</html>
Out-Put:-
Replace all spaces with underscores while textbox value using JQuery
Reviewed by NEERAJ SRIVASTAVA
on
4:54:00 PM
Rating:
No comments: