<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: adhham</title>
    <description>The latest articles on DEV Community by adhham (@adhhamofficial).</description>
    <link>https://dev.to/adhhamofficial</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F358888%2F4568f693-0dc7-49e7-b630-9b5b46227d7f.jpg</url>
      <title>DEV Community: adhham</title>
      <link>https://dev.to/adhhamofficial</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adhhamofficial"/>
    <language>en</language>
    <item>
      <title>You Are Using The Number Input Incorrectly</title>
      <dc:creator>adhham</dc:creator>
      <pubDate>Sun, 16 Feb 2025 13:23:18 +0000</pubDate>
      <link>https://dev.to/adhhamofficial/you-maybe-using-the-number-input-wrongly-4c4f</link>
      <guid>https://dev.to/adhhamofficial/you-maybe-using-the-number-input-wrongly-4c4f</guid>
      <description>&lt;p&gt;TIL I have been using the number inputs incorrectly and I've seen many others do the same.&lt;/p&gt;

&lt;p&gt;HTML number input should not be used on just any type of number; It is designed to be used only for numbers that are incremental and is not appropriate for non-incremental values even if they are made up of numbers. &lt;/p&gt;

&lt;p&gt;So this means it can be used to capture an amount of something such as the number of products to purchase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- ✅ Correct ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"products"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Number of products to buy: &lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"products"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"products"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it cannot be used for phone numbers, postal codes and credit card numbers, because these are not incremental numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- ❌ Wrong ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Phone number:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also explains why it has a stepper button (in most browsers), which doesn't make much sense for phone numbers or credit card numbers.&lt;/p&gt;

&lt;p&gt;According to the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#using_number_inputs" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The number input type should only be used for incremental numbers, especially when spinbutton incrementing and decrementing are helpful to user experience. The number input type is not appropriate for values that happen to only consist of numbers but aren't strictly speaking a number, such as postal codes in many countries or credit card numbers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To capture postal codes (and other non-incremental values) use &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; with &lt;code&gt;inputmode&lt;/code&gt; attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- ✅ Correct ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"postal_code"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Postal Code:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"postal_code"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;inputmode=&lt;/span&gt;&lt;span class="s"&gt;"numeric"&lt;/span&gt; &lt;span class="na"&gt;pattern=&lt;/span&gt;&lt;span class="s"&gt;"\d*"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For phone numbers &lt;code&gt;&amp;lt;input type="tel"&amp;gt;&lt;/code&gt; can also be used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- ✅ Correct ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Phone number:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"tel"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"phone_no"&lt;/span&gt; &lt;span class="na"&gt;pattern=&lt;/span&gt;&lt;span class="s"&gt;"[0-9]{3}-[0-9]{3}-[0-9]{4}"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read more on MDN:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;input type="number"&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode" rel="noopener noreferrer"&gt;&lt;code&gt;inputmode&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;input type="tel"&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>programming</category>
      <category>htmltips</category>
    </item>
    <item>
      <title>How to Fix No Internet Connection in Digital Ocean's Droplet</title>
      <dc:creator>adhham</dc:creator>
      <pubDate>Thu, 26 Dec 2024 16:10:48 +0000</pubDate>
      <link>https://dev.to/adhhamofficial/how-to-fix-no-internet-connection-in-digital-oceans-droplet-1c66</link>
      <guid>https://dev.to/adhhamofficial/how-to-fix-no-internet-connection-in-digital-oceans-droplet-1c66</guid>
      <description>&lt;p&gt;Digital Ocean stores its network configuration in two interfaces: &lt;code&gt;eth0&lt;/code&gt; and &lt;code&gt;eth1&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;eth0&lt;/code&gt; is used for public network (aka. The Internet)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;eth1&lt;/code&gt; is used for internal private network (ie. digital ocean's  internal network)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The correct naming of these interfaces is a must for it to work properly; it should have the exact same name.&lt;/p&gt;

&lt;p&gt;In your droplet, run &lt;code&gt;ip -br a&lt;/code&gt; command to see if these two interfaces are correctly configured. If you see an output like this, it means the interfaces are not up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ip &lt;span class="nt"&gt;-br&lt;/span&gt; a
eth0 DOWN
eth1 DOWN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;To follow this tutorial you will need the public IP address and router gateway IP of your droplet. The public IP can be found in your droplet's dashboard page. &lt;strong&gt;&lt;em&gt;If you don't know your gateway IP address, I recommend lodging a support ticket.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To configure &lt;code&gt;eth0&lt;/code&gt; or public network interface, run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ip addr add 123.456.78.9/20 dev eth0
&lt;span class="nv"&gt;$ &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;eth0 up
&lt;span class="nv"&gt;$ &lt;/span&gt;ip route add default via 123.456.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;123.456.78.9/20&lt;/code&gt; with your droplet's public IP address and &lt;code&gt;123.456.0.1&lt;/code&gt; with the gateway IP address.&lt;/p&gt;

&lt;p&gt;Now, configure the nameservers. Edit &lt;code&gt;/etc/resolv.conf&lt;/code&gt; file and add the following nameservers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nameserver 8.8.8.8
nameserver 8.8.4.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply the netplan configurations to make these changes persistent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;netplan &lt;span class="nt"&gt;--debug&lt;/span&gt; generate
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;netplan &lt;span class="nt"&gt;--debug&lt;/span&gt; apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the &lt;code&gt;ip -br a&lt;/code&gt; command again. If it gives a similar output to the one shown below, it means the interface has been configured.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ip &lt;span class="nt"&gt;-br&lt;/span&gt; a
eth0 UP 123.456.78.9/20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can test this by pinging to a website. Try &lt;code&gt;ping google.com&lt;/code&gt; and see if it is working correctly.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>fix</category>
    </item>
  </channel>
</rss>
