Skip to content

How to format expiry credit card date MM/YYYY

I need to format an expiry date for credit card in the following format MM/YYYY using a regex which looks like this ^(0[1-9]|1[0-2])/?([0-9]{4})$ but when it comes to add slashes it groups everything in 2. The question here is how do I add slashes only after first 2 instead of each 2? Answer

Reorder select option list using Vanilla JS

Hi I’ve got an option dropdown list with a list of fruit in alphabetical order with some that out of stock. What i’m trying to achieve is moving the out of stock options in the dropdown to the bottom of the list so the in stock items are displayed above those that are out of stock. My idea was to

Youtube’s custom right click menu options

I was using youtube and realized that if you right-click a video twice (once to bring up youtube’s right-click menu, and a second time while its menu is already up) it opens the browser’s right-click menu with additional options. Specifically, on Firefox, it has the added options: Play, Mute, Spee…

Add text to SVG path dynamically

I have an SVG exported from Adobe Illustrator with several paths like this, which produces a small polygon I intend to use as a text box I’d like to dynamically add text to it. I’ve seen many similar questions here, but most of them involed specifying a x and y property for a text element based on…

Iframe load event fires twice

The function bound to (@load=”myFunction”) fires once when the iframe is created and once when it’s actually loaded. Why does it fire when the iframe is created, and how to avoid it? Answer As @tao suggested something else was interefering, namely Nuxt Lazy Load package. So if anyone uses th…