How To Join Two TextBox Values Using Javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoName.aspx.cs"
Inherits="AutoName" %>

<!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>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
      <div>
          <asp:TextBox ID="firstName" runat="server" onkeyup="autoname( );" Text="First" />
          <asp:TextBox ID="lastName" runat="server" onkeyup="autoname( );" Text="Last" />
          <asp:TextBox ID="fullName" runat="server" Text="" />
      </div>
  </form>

  <script type="text/javascript">

  function autoname( )
  {
      var temp = document.getElementById( "firstName" ).value.toLowerCase( );
      temp += " "+ document.getElementById( "lastName" ).value.toLowerCase( );

      document.getElementById( "fullName" ).value = temp;
  }

  autoname( );

  </script>

</body>
</html>

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads

CodeGuru