ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Show only the first and last four digit of a number using JavaScript<p>Hi <a class="username" rel="Alauddin"> Alauddin</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:Label ID=&#34;lblTable&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34;&gt; window.onload = function () { var table = document.getElementsByTagName(&#34;table&#34;); var trs = table[0].getElementsByTagName(&#39;tr&#39;); for (var i = 0; i &lt; trs.length; i++) { var tds = trs[i].getElementsByTagName(&#39;td&#39;); var cardno = tds[1].innerText; if (cardno.length &gt; 5) { var firstFour = cardno.substr(0, 4); var lastFour = cardno.substr(cardno.length - 4, cardno.length); var middle = cardno.substr(4, cardno.length - 8).replace(/[0-9]/g, &#34;*&#34;); var newLink = document.createElement(&#34;a&#34;); newLink.setAttribute(&#34;href&#34;, &#34;https://www.Test.com/&#34; + cardno); text = document.createTextNode(firstFour + middle + lastFour); newLink.appendChild(text); tds[1].appendChild(newLink); } } } &lt;/script&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System; using System.Text;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { StringBuilder sb = new StringBuilder(); sb.Append(&#34;&lt;table id=&#39;01717458720_CardList&#39;&gt;&#34;); sb.Append(&#34;&lt;tr&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;product_type&#39;&gt;CREDIT CARD&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_no&#39; abbr=&#39;*&#39;&gt;1111234567123456&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_status&#39;&gt;INACTIVE&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;acct_no&#39;&gt;N/A&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;name&#39;&gt;Mr. X&lt;/td&gt;&#34;); sb.Append(&#34;&lt;/tr&gt;&lt;tr&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;product_type&#39;&gt;DEBIT CARD&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_no&#39;&gt;0000000000000000&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_status&#39;&gt;ACTIVE&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;acct_no&#39;&gt;55555555555&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;name&#39;&gt;Mrs. Y&lt;/td&gt;&#34;); sb.Append(&#34;&lt;/tr&gt;&lt;/table&gt;&#34;); lblTable.Text = sb.ToString(); } }</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><span style="text-decoration: underline;"><strong><img src="https://imgur.com/SIlGV8k.jpg" alt="" width="472" height="142" /></strong></span></p>https://www.aspforums.net:443/Threads/142386/Show-only-the-first-and-last-four-digit-of-a-number-using-JavaScript/https://www.aspforums.net:443/Threads/142386/Show-only-the-first-and-last-four-digit-of-a-number-using-JavaScript/Tue, 25 Sep 2018 04:20:42 GMT