Skip to main content

How to Create a Simple Phone Number Picker

Phone numbers, besides names and emails, are the most frequently used contact information in online forms. Phone number fields are usually designed in a way that requires users to type the numbers in using their keyboards. This method frequently results in inaccurate data input.

To reduce user input errors and improve the user experience of your site, you can create a GUI that allows users to quickly enter their phone number, in a way that is similar to date pickers.

Useful Calendar & Date Picker Scripts For Web Developers

Useful Calendar & Date Picker Scripts For Web Developers

Calendars can be seen frequently in most web pages today especially in blogs and personal websites. As for…Read more

In this tutorial, you’ll see how to add a simple phone number picker to an input field. We’ll use HTML5, CSS3 and JavaScript to get to the GUI you can see and test in the demo below. We’ll also put regular expressions in use to make sure users really enter a valid phone number.

1. Create the Phone Number Field

First, create an input field with a dial icon on the right that will open the dial screen on click. The dial icon just looks like 9 black boxes, arranged 3 by 3, must like what you see on a regular phone.

I’m using the tel input type for proper HTML5 semantics, but you can also use the text input type if you want.

 <div id="dialWrapper">     <input id="phoneNo" type="tel">     <img id="dialIcon" src="dialIcon.png"> </div> 

HTML Base of the Phone Number Picker

2. Create the Dial Screen

The dial screen is a grid of numbers from 0 to 9 plus some special characters. It can be made with either a HTML <table> or JavaScript.

Here, I’ll show you how to create the dial screen table in JavaScript. You can, of course, add the table directly in the HTML source code if you prefer it that way.

First, create a new 'table' element in the DOM by using the createElement() method. Also give it the 'dial' identifier.

 /* Create dial screen */ var dial = document.createElement('table'); = 'dial'; 

Add a for loop to insert the four rows of the dial table with it. Then, for each row, run another for loop in order to add three cells per row. Mark each cell with the 'dialDigit' class.

 for (var rowNum = 0; rowNum < 4; rowNum++) {     var row = dial.insertRow(rowNum);     for (var colNum = 0; colNum < 3; colNum++) {         var cell = row.insertCell(colNum);         cell.className = 'dialDigit';         cell.textContent = ((colNum + 1) + (rowNum * 3)).toString();     } } 

The two for loops above calculate the digits that go into the cells of the dial table — the values of the cell.textContent property — in the following way:

 (colNum + 1) + (rowNum * 3) /* first row */ (0 + 1) + (0 * 3) = 1 (1 + 1) + (0 * 3) = 2 (2 + 1) + (0 * 3) = 3 /* second row */ (0 + 1) + (1 * 3) = 4 (1 + 1) + (1 * 3) = 5 (2 + 1) + (1 * 3) = 6 /* etc. */ 

The last row is different, as it consists of two special characters, - and + that are used in phone number formats to identify regional codes, and the digit 0.

To create the last row to the dial screen, add the following if statement to the inner for loop.

 for (var rowNum = 0; rowNum < 4; rowNum++) {   var row = dial.insertRow(rowNum);   for (var colNum = 0; colNum < 3; colNum++) {     /* if last row */     if (rowNum === 3) {       cell = row.insertCell(colNum);       cell.textContent = '-';       cell.className = 'dialDigit';       cell = row.insertCell(colNum);       cell.textContent = '0';       cell.className = 'dialDigit';       cell = row.insertCell(colNum);       cell.textContent = '+';       cell.className = 'dialDigit';       break;     }     cell = row.insertCell(colNum);     cell.className = 'dialDigit';     cell.textContent = ((colNum + 1) + (rowNum * 3)).toString();   } } 

The dial screen is now complete, add it to the #dialWrapper HTML container you created in Step 1 by using two DOM methods:

  1. the querySelector() method to select the container
  2. the appendChild() method to append the dial screen — held in the dial variable — to the container

Dial Screen Table without Styling

3. Style the Dial Screen

To make it more attractive, style the dial screen with CSS.

You don’t necessarily have to stick with my styling, but don’t forget to add user-select:none; property to the #dial container so that while the user is clicking on the digits, the text won’t get selected by the cursor.

 #dial {       width: 200px;       height: 200px;       border-collapse: collapse;       text-align: center;       position: relative;       -ms-user-select: none;       -webkit-user-select: none;       -moz-user-select: none;       user-select: none;       color: #000;       box-shadow: 0 0 6px #999; } .dialDigit {       border: 1px solid #fff;       cursor: pointer;       background-color: rgba(255,228,142,.7); } 

Dial Screen Table with Styling

4. Show the Dial Screen on Click

First, add the visibility:hidden; style rule to #dial in the above CSS to hide the dial screen by default. it’ll be only shown when the user clicks on the dial icon.

Then, add a click event handler to the dial icon with JavaScript to toggle the visibility of the dial screen.

To do so, you need to use the aforementioned querySelector() and the addEventListener() methods. The latter attaches a click event to the dial icon and calls the custom toggleDial() function.

The toggleDial() function changes the visibility of the dial screen from hidden to visible, and back.

 document.querySelector('#dialIcon').addEventListener('click', toggleDial);  function toggleDial() { = === 'hidden' || === ''     ? 'visible' : 'hidden'; } 
5. Add the Functionality

Add a custom function that inputs digits into the phone number field on the click of the cells of the dial screen.

The dialNumber() function appends the digits one by one to the textContent property of the input field marked with the #phoneNo identifier.

 phoneNo = document.querySelector('#phoneNo'); function dialNumber() {     phoneNo.value += this.textContent; } dialDigits = document.querySelectorAll('.dialDigit'); for (var i = 0; i < dialDigits.length; i++) {     dialDigits[i].addEventListener('click', dialNumber); } 

Now, you have a working dial screen to input phone number field.

To keep up with the CSS, change the background color of the digits in their :hover and :active (when the user clicks on it) states.

 .dialDigit:hover{       background-color: rgb(255,228,142); } .dialDigit:active{       background-color: #FF6478; } 
6. Add Regular Expression Validation

Add a simple regex validation to validate the phone number while the user enters the digits into the input field. According to the validation rules I use, the phone number can only start with either a digit or the + character, and accept the - character afterwards.

Beginner’s Guide to Regular Expression (Regex)

Beginner’s Guide to Regular Expression (Regex)

A regular expression is a set of characters forming a pattern that can be searched in a string.…Read more

You can see the visualization of my regular expression on the screenshow below created with the Debuggex app.

Regex visualization from

You can also validate the phone number as per the phone number format of your country or region.

Create a new Regular Expression object, and store it in the pattern variable. Also create a custom validate() function that checks if the entered phone number complies with the regular expression, and if it’s at least 8 characters long.

When the input doesn’t validate, the validate() function needs to give feedback to the user.

I’m adding a red border to the input field when the input is invalid, but you can inform user in other ways, for instance, with error messages.

 pattern = new RegExp("^(+d{1,2})?(d+-*d+)*$ "); function validate(txt) {   // at least 8 characters for a valid phone no.   if (!pattern.test(txt) || txt.length < 8) { = '2px solid red';     return false;   } else = 'initial';   return true; } 
7. Perform the Validation

The validate() functions needs to be called in order to perform the validation. Call it from the dialNumber() function you created in Step 5 in order to validate the value of the phoneNo variable.

Note that I also added an additional validation for maximum characters (can’t be more than 15) by using an if statement.

 function dialNumber() {         var val = phoneNo.value + this.textContent;         // maximum characters allowed, 15         if (val.length > 15) return false;         validate(val);         phoneNo.value = val; } 

Your phone number picker is now ready, check out the final demo below.

Let’s block ads! (Why?)


Seafood White Beehoon: Beginning of a new trend

Seafood White Beehoon 2

Years from now,  when you sit down with your kids (would be grandkids for me) for a plate of seafood white beehoon and they ask you about the origins of this particular dish, you can tell them exactly how this dish became popular in Singapore!

“A long long time ago, in the Northern part of Singapore… a place called Sembawang…. in those days, Sembawang was still quite remote,  with quaint little shophouses, not like the city that it is today……..(strokes goaty)…… There was a Zi Char restaurant called You Huak which was famous for a dish called white beehoon…..”

Crayfish and beehoon

Yes, white beehoon (白米粉) was a dish which the owners at You Huak invented a few years ago.  Very soon, word got around and queues started to form outside their Zi Char restaurant.  I first got wind of it a few years back during reservist training at Nee Soon Camp when one of my colleagues, a gynaecologist, kept raving about this particular 白米粉.  So of course we had to brave the queues to get a taste of the dish.  I must admit that my first impression was quite underwhelming.  But after a few more visits, I came to appreciate the dish.

Anyway, they did so well that they started a new restaurant at Ponggol Point called White Restaurant, which was named after their white beehoon……presumably.  Soon after this, a few independent hawker stalls started sprouting up all over Singapore selling similar seafood bee hoon, like this stall in Ang Mo Kio.


The man behind the wok is Chef Simon who started the stall having returned to Singapore after spending many years as a Chinese restaurant chef in London.  When asked why he chose this particular dish, he simply said that there weren’t many stalls selling it.

This stall was very highly recommended by our makan kakis and was the 2nd stall we visited in recent weeks.  The first stall was also recently opened by our friend Francis from Cafe de Hong Kong.  His stall, called Xian Seafood White Bee Hoon is located at Block 304 Ubi Ave 1.  We went when they had just started operations and I felt the kitchen could do with a bit of shake down time.  But knowing Francis, it should be up to speed by now.

Truth be told, my initial reaction to this particular white bee hoon was  not “Wow! This is darn shiok lor!”.  But then again, neither was my initial reaction to the white beehoon at You Huak.  However, my kakis all seem to enjoy it, which is why I decided to write the story.

What I do appreciate is the fact that Chef Simon uses fresh crayfish and prawns to cook the dish.  So, the quality of the seafood is very good.  The broth is sweet but I felt it still lacked that X factor and the beehoon could have had a bit more of that smokey wok flavour.  4/5



I think it is quite safe to say that 2016 is the year when Seafood White Beehoon was unofficially added to our Singaporean list of hawker dishes!  This stall in Ang Mo Kio is one of several new stalls around and is worth a visit if you are looking for this dish.

Have you been caught up in the Seafood White Beehoon trend yet? Please do share with us your favourite stall!

Let’s block ads! (Why?)



Ha Ha Bin Hokkien Mee: Makings of a Master

Hokkien Mee 1Hokkien Mee $ 5

You know those heartwarming videos that MOE puts out to get more people to enter the teaching profession?  Yeah, the ones that show a super dedicated teacher who believed in a particular student even though he was a real pai kia (gangster) and because of his persistence, the pai kia eventually becomes a lawyer or motivational speaker?

Well, it’s because of such a teacher that I got to know of 21 year old Chua Yida who recently took over a hokkien mee stall in Chinatown Food Centre.

Melvyn first wrote to me through Facebook and then again several days later through email to tell me about his ex-student who had just started this hokkien mee stall.  Chua Yida didn’t do well enough to further his education and subsequently got into problems with the law which landed him under probation.  All this while, Melvyn continued to be his mentor and finally persuaded him to start afresh with this hokkien mee stall.

So, now you know that these sort of stories really happen in real life!

Kudos to all the teachers out there and Happy belated Teachers’ Day!


Now, I am not writing this story just because it is heartwarming.  As a reader of this blog, you know that no story ever gets written unless the food is worth the calories.  But I do have a soft spot for the underdog, so I responded to Melvyn’s email by paying Yida a visit.  I must admit that at that stage, all I thought I was going to do was to give Yida some tips on how to improve his hokkien mee.  After all, how good can a hokkien mee from such a young hawker be?

But that changed when I got my first taste of the noodles. It was an “anton ego” moment and I was momentarily transported back to my childhood days when I had to wrestle with my two brothers for my share of the one single opeh wrapped packet of hokkien mee!  It was well fried with a wonderful charred flavour and the stock was delicious!


It turns out that even though Yida was only 21, he already had many years of experience frying hokkien mee.  He started learning the technique while still at school and would often spend the evenings working at a hokkien mee stall.  When I spoke to him, it struck me that he had really thought through the whole process frying that perfect plate of hokkien mee and wasn’t afraid of trying new ways of making it even better!

There are several keys to a great hokkien mee.  Firstly, the noodles have to be fried well so that the exterior is slightly charred.  This is often not done as it takes too much time and most hawkers will just give it a cursory excursion round the wok and depend on an msg laden stock to power the noodles.  Yida understands this and as you can see in the video, the noodles are fried till the noodles give off a toasty aroma before he adds the stock.

Secondly, the stock has to be good.  Not only does it have to be tasty, it needs to have a bit of gelatin so that when it is reduced, it has that lip smacking stickiness.  Yida tells me that he uses only fresh sea prawns, pork belly and lala clams to give his stock its flavour and extra pork skin for that sticky texture.

But that is not all, what impressed me most about Yida is his willingness to explore new ways to improve on his hokkien mee.  If you watch the video, you will notice that he covers his noodles twice, once at the start of the frying process and then again at the end.   Most stalls would start by frying the noodles first and then add the stock right at the end.  He told me that he came up with this method through trial and error and it made the noodles tastier.  He also revealed that in order to make his stock tastier, he would fry the prawn heads first, like what is done with prawn mee soup.

NB:  I do remember some stalls adding the stock twice, but they always do it after frying the noodles for a bit.  Yida actually adds in the stock right at the beginning which is quite unique.

Just to moderate your expectations, I think that his current wok fire is not big enough to allow him to fry more than five plates at a time.  So, if you go when it is busy, the noodles might lack that charred flavour.  He is also still working on perfecting the sambal chilli and has started using dried shrimps to give it more flavour but it still needs a bit of tweaking.  By itself it is very tasty, but the chilli recipe needs to be formulated so that it blends well with the rest of the noodles.  It is a little on the sweet side and although the spiciness level is good with me, those looking for really spicy sambal would be disappointed.  4.25/5



It is good to see a Gen Z hawker with such passion for hokkien mee! Right now Yida is able to fry a plate of hokkien mee which would give the masters a run for the money.  The only real problem may be a lack of consistency when there is a crowd.  But I am confident that if this young man is persistent, he will become a hawker master in due course.

Let’s block ads! (Why?)



Repeat And Shuffle In iOS 10 Music App: Here’s Where They Have Moved

By | September 22nd, 2016

Having trouble locating Repeat and Shuffle options in iOS 10 Music app? Here’s where exactly they are located in the app.

One of the biggest app changes in iOS 10 comes with the new Music app. Apple’s designers and engineers have worked with the Apple Music platform, which is accessed via the Music app on iOS, to try and make it more user-friendly with clearly defined sections, but to also try and focus on the content, such as the stunning album art.


The jury is still out on whether or not they have achieved their vision with the revamped interface, but it’s definitely clear that certain things have been moved around from iOS 9 to iOS 10, therefore leaving users a little confused. The ability to put a song on repeat or shuffle songs is one of those things that’s been moved, and moved out of sight for that matter, and many users are apparently having trouble locating them. Here we’re going to take a look at where Apple has moved these options in the revamped Music app in iOS 10.

Step 1: This one really goes without saying, but you are going to need to actually launch the Music app on your device in order to play a song, let alone have one play on repeat.

Step 2: When the Music app has launched, find a song that you want to play on repeat or for that matter shuffle the playlist. This could be an individual song that you search for via the Apple Music catalog, or one that’s already in a playlist or even stored on the device itself if you have any music synced via iTunes. Start playing the song.

Step 3: Like a lot of popular music streaming services and apps, when a song is playing via Apple Music, the mini-player appears in a static bar at the bottom of the display. Tap on the Now Playing mini player at the bottom to bring it into full-screen, which is essentially the main Now Playing card.


Step 4: Swipe up here to scroll right down, which will show the Up Next section, which basically just shows what tracks the Music app is going to play after the current song. At the right side of that Up Next section is where you will see the two icons for Shuffle and Repeat.


And that’s it. Tap on the Repeat icon – which is indicated by two arrows giving the impression of a circle – to ensure that the currently playing song is repeated. Similarly, you can tap the Shuffle icon – indicated by two arrows crossing each other – to shuffle and play random songs from a playlist.

You may also like to check out:

Related Stories

Let’s block ads! (Why?)

Redmond Pie


Quan Soon Wanton Noodle @ Teban Garden Food Centre – One Of The Cheapest Wanton Mee At $2


Further down the row of stalls of JH Fishball Noodle at Teban Garden Food Centre is Quan Soon Wanton Noodle. Quan Soon Wanton Noodle is owned by 62 years old Madam Wong who has been offering cheap and affordable food for the neighbourhood for the past 37 years. You can get a plate of wanton mee for $ 2 at her stall.

Wanton Mee 3.5/5

The stall sells a variety of noodle dishes such as Wanton Mee, Laksa and Prawn Noodle, all at a low price of $ 2. Madam Wong has continued to sell her noodles at $ 2 because there are many old people which do not have a lot of money in the estate and she wanted to provide affordable food which can help to fill their stomach.

Wanton Mee 3.5/5

My plate of wanton mee dry for a mere $ 2 comes with springy noodles, 2 wantons, slices of char siew  and some vegetables. I enjoyed the texture of the noodle as well as the wanton which is stuffed with minced pork and chestnut, I can even taste hints of dry sole fish in the wanton filling.

For those that is looking for something for substantial, you can also go for the larger portion at $ 2.50 or $ 3. The plate of wanton mee may not be the best but it does come with that old school flavours, bringing back my childhood memories.

Quan Soon Wanton Noodle
Teban Garden Food Centre
Blk 37A Teban Garden Road
Singapore 601037
Nearest MRT: Jurong East (EW Line, NS Line)

Opening Hours:
Daily: 5am – 730pm

1) Alight at Jurong East MRT station. Take Exit A. Walk to Jurong East Bus Interchange (Stop ID 28009). Take bus number 143. Alight 6 stops later. Walk to destination. Journey time about 18 minutes. [Map]

2) Alight at Jurong East MRT station. Take Exit A. Walk to Jurong East Bus Interchange (Stop ID 28009). Take bus number 79. Alight 7 stops later. Walk to destination. Journey time about 18 minutes. [Map]

Let’s block ads! (Why?)

SG Food on Foot | Singapore Food Blog | Best Singapore Food | Singapore Food Reviews


How To Shoot RAW Photos On iOS 10 iPhone And iPad

By | September 21st, 2016

Here’s how to shoot photos on iOS 10 in RAW image format using a supported iPhone, iPad or iPod touch device’s camera.

Now that you’ve got Apple’s latest mobile OS installed on your device, you’re probably going to want to be in a position to take advantage of the new features that Apple has made available. Some of those features are immediately evident – such as the hugely revamped Messages app – whereas others, such as the native ability to shoot RAW photos from an iOS device aren’t immediately evident unless you have an installed app capable of leveraging that functionality.


Before getting down to the details, for those of you who are wondering what they stand to benefit from shooting RAW images, photos captured in this particular format are basically free of any post image processing or adjustments that most smartphones, including the iPhone, make when saving the photo. This allows professionals or avid editors greater control over image editing and adjustments.

What’s even more amazing is that the feature is not exclusive to the iPhone, and that the iPad has also been enveloped into this awesome offering. Though the compatible devices, due to hardware limitations, only includes iPhone 7, iPhone 7 Plus, iPhone 6s, iPhone 6s Plus, iPhone SE, and the 9.7-inch iPad Pro. So without further ado, here’s how you can go about capturing RAW photos using your compatible iOS 10-powered device.

Step 1: In order to take advantage of the new RAW capabilities within iOS 10, you’re going to need a camera app that has been built to take advantage of that feature. There are many that already exist in the App Store, but we’re going to run through the process using the Manual app which costs $ 3.99.

Step 2: When you’ve downloaded the app, you will of course need to launch it just like you would with any other app. Tap on the Settings cog icon in the app that’s located in the bottom right-hand corner. This will produce a new menu over the top of the view finder.

Step 3: The top toggle in the new menu will be titled Save RAW + JPEG. Make sure that this toggle is turned on to enable the feature.


Step 4: The app will then produce a separate action sheet from the bottom of the display with two options: RAW and RAW + JPEG. This is asking if you want to save any captured image purely as a RAW file in DNG format, or if you want to save two individuals files as RAW and JPEG. Choosing the latter will of course take up additional space on the device as you will essentially be saving two files.

And that’s all she wrote. Using the Manual app to take images will now honor the chosen options from above and save either a single RAW image, or a RAW image plus a JPEG file.

Using the Manual app as outlined above is only one way of actually capturing images in a RAW format. There are other apps too, like Obscura ($ 4.99) and ProCamera ($ 4.99), that takes advantage of Apple’s new APIs in iOS 10 for shooting RAW photos, with many more camera apps likely on their way which will also provide this functionality. It really comes down to personal preference and which app offers the best additional functionality that actually suits your needs as a photographer.

You may also like to check out:

Related Stories

Let’s block ads! (Why?)

Redmond Pie


Top 5 Best Curry Rice in Singapore

1What is Hainanese Curry Rice?

Hainanese curry rice is a Chinese Singaporean dish consisting of steamed white rice smothered in a mess of curries and gravy, characteristically accompanied by curry chicken, pork chop, chap chye (braised cabbage) and kong bak (braised pork). It originates in Singaporean cuisine and is not thought of as part of the cuisine of Hainan, China.

Hainanese curry rice developed during British colonial rule in Singapore. It was started by Hainanese living in Singapore, who were often employed by the British as well as the wealthy Peranakans (Straits-Chinese) as chefs in their homes.

Pork chop was adapted from British cuisine and the rest of the ingredients, such as curry chicken, babi pongteh and chap chye, were from Peranakan cuisine. These were adapted for Hainanese curry rice. At that moment, it was an instantly recognized dish.

Here is the list of top 5 best curry rice in Singapore

Let’s block ads! (Why?)

I Eat & Eat


iPhone 7 Vs iPhone 7 Plus Vs Every Other iPhone Model Ever [Video]

By | September 20th, 2016

Here’s iPhone 7 vs iPhone 7 Plus vs iPhone 6s vs iPhone 6s Plus vs every other iPhone model ever speed test on video.

The iPhone 7 and iPhone 7 Plus are now a weekend-old and everyone is getting to know their new smartphone. We’ve already heard reports of some handsets emitting a strange hissing sound when their A10 CPU is under load, but generally it has been a successful launch, with the iPhone 7 Plus proving more popular. The reasons for the newest iPhone being a strong release are not too difficult to fathom. With a slightly designed exterior but rebuilt interior, the new iPhone 7 and iPhone 7 Plus are the fastest iPhones yet, and that’s ignoring the fancy new camera system, especially on the dual-lens-camera-wielding iPhone 7 Plus. Going back to the sheer speed of the devices for a minute though, just how fast are they?


It is now perfectly normal for Apple to produce new graphs alongside new iPhones which claim to show that they are considerably faster than their predecessors, and that is to be expected. You would always expect an iPhone 7 to be faster than the original iPhone, for example,. but have you ever wondered just by how much? If you have, then you’re in luck.

Just because the best way to illustrate anything these days is via a video, and here we have a video that highlights just how fast the iPhone 7 and iPhone 7 Plus are by comparing them with every model of iPhone ever made. That means there are now fewer than 15 iPhones being put through their paces in the video, with benchmarks, camera tests and audio gauging carried out in order to quantify just how good the latest handsets are. The answer? Very good indeed.

Check the video out for a full rundown of how the various iPhones fared. It makes for interesting viewing.

Apple launched the iPhone 7 and iPhone 7 Plus this past Friday, with devices being snapped up around the globe. Despite the lack of a headphone port and the fact next year’s iPhone is predicted to be something special because of the tenth anniversary of the original iPhone’s launch, the iPhone 7 and its larger brother have been well received with all Plus models being sold out even before the retail launch. These speed tests won’t hurt them, either.

(source: EverythingApplePro [YouTube])

You may also like to check out:

Related Stories

Let’s block ads! (Why?)

Redmond Pie