Recently I was tasked with writing a regular expression that would check for a valid Australian phone number for both landline and mobile phone variants whilst allowing for different formats (spaces, no spaces, international dialing code, brackets, area code, no area code).
The below regular expression code and subsequent tests are for Australian mobile and landline numbers only, but could be tweaked to work for other countries as well.
The expression `// This is our bread and butter expression var phoneExpression = /^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/; // Valid var phoneNumber1 = "0411 234 567"; var phoneNumber2 = "(02) 3892 1111"; var phoneNumber3 = "38921111"; var phoneNumber4 = "0411234567"; // Invalid var phoneNumber5 = "3892 11"; var phoneNumber6 = "diane 0411 234 567"; var phoneNumber7 = "bob"; if (phoneNumber1.match(phoneExpression)) { console.log('Valid 10 digit mobile number'); } if (phoneNumber2.match(phoneExpression)) { console.log('Valid 8 digit landline number with circular brackets wrapping area code'); } if (phoneNumber3.match(phoneExpression)) { console.log('Valid 8 digit landline number with no spaces or area code'); } if (phoneNumber4.match(phoneExpression)) { console.log('Valid 10 digit mobile number with no spaces or international dialing code'); } if (!phoneNumber5.match(phoneExpression)) { console.log('Invalid landline number which is 6 digits instead of 8'); } if (!phoneNumber6.match(phoneExpression)) { console.log('A name and space before a valid spaced 10 digit mobile number'); } if (!phoneNumber7.match(phoneExpression)) { console.log('No valid number entered, a name appears to have been entered instead'); }` Supported formats: 0411 234 567, +61411 234 567, (02) 3892 1111, 38921111, 3892 111, 02 3892 1111
Recently whilst trying to use the Zurb Foundation Abide validation component I ran into an issue where I was getting a bizarre error involving form validation.
The error message might vary, but it’ll look similar to this: Error: Syntax error, unrecognized expression: [data-‘Times New Roman’-abide]
The issue stems from the fact Foundation utilises an internal namespace. All you have to do is set the namespace to be blank and everything appears to start working:
At work our internet connection is painfully slow for the moment while we sort something better out and I ran into a rather interesting quirk whilst using Composer and timeouts.
I was trying to install Laravel and because of the sheer number of components it got part of the way through and then would display some error message about exceeding the timeout limit of 300 seconds (5 minutes).
The reason for this appears to be due to the fact my Internet connection is mega slow and some components being largish in size. When calling composer update or composer install you just need to specify a higher timeout value.
Currently Bootstrap is still the preferred choice for prototyping web applications and rapidly getting a MVP out the door. As great and undeniably helpful it is, Bootstrap is far too opinionated to be a viable front-end CSS solution for a lot of people. It throws the kitchen sink at you and its default style.
There are numerous themes for Bootstrap and means of creating your own styles, but as someone who’s now worked with Bootstrap quite extensively, it feels like you’re constantly overriding base styles (even using Bootstrap Sass won’t help you).
Newcomers to Node.js will have run into this issue a couple of times. You get your setup working, you’ve built a little application and on your server you start your Node app, but then you close the terminal window and your application stops.
When I first started using Node.js, this is the first thing I Googled, “How do I keep a Node.js app running after I close the terminal console?”
Chances are you are living in the past or working on a project that was built in the past that is still marking up content using DIV tags instead of semantic tags like article and section.
Don’t get me wrong, there is nothing wrong with using DIV tags and there will always be a use for them, some pieces of content should be marked up using tags with semantic meaning. They’re not only cleaner, but also help bolster your chances of ranking better on the likes of Google.
This is the one aspect of jQuery and well, Javascript, in general, I see newcomers to Javascript and jQuery get caught upon. Heck, I’ve seen veterans get caught up on how to properly cancel and allow events as well as event bubbling.
Nothing. There is no opposite method of “event.preventDefault()” to understand why you first have to look into what event.preventDefault() does when you call it.
Underneath the hood, the functionality for preventDefault is essentially calling a return false which halts any further execution. If you’re familiar with the old ways of Javascript, it was once in fashion to use return false for cancelling events on things like form submits and buttons using return true (before jQuery was even around).
Everyone wants to build the next Facebook, the next Google, the next Instagram and the next big thing. The harsh reality is that only a handful of people every so often actually make it. For every Mark Zuckerberg there are probably tens of thousands of entrepreneurs toiling away in cafes, the early hours of the morning and weekends who end up not “making it” presumably because only a very small percentage of entrepreneurs actually do.
If you’re like a lot of developers out there, you start your projects off with the best of intentions. No developer ever says, “I am going to make this project a fucking mess, a cluster-fuck of spaghetti code that even I’ll struggle to read in 2 weeks, let alone any other developer”
We’re living in the golden-age of front-end development. We have tools, we have awesome methodologies like BEM and CSS pre-processors like Sass. And for all that automation without a proper structure, our CSS always ends up being unorganised and messy.
For some time now there has been a slowly growing movement amongst particular designers and developers against WordPress. We’ve seen light CMS’s, decoupled PHP frameworks, open source alternatives and the big one: static site generators, but no matter the alternative, it seems it’s for the wrong intentions.
What WordPress Is Firstly, WordPress is a content management system that started out as a blogging platform. I’d actually argue WordPress is a framework of sorts in that it provides you with; user authentication, plugins sytem, themes system, helper classes and a loose structure which it expects you to follow (but isn’t overly strict on).