I’ve recently been looking for a regular expression to do some client side date checking, and I haven’t been able to find one that can satisfy the following criteria: Has a range from 1800 – Now Performs proper date checking with leap years MM/DD/YYYY Form Invalid Date Checking (These constraints were outside of my scope and are a requirement as
How to highlight text using javascript
Can someone help me with a javascript function that can highlight text on a web page. And the requirement is to – highlight only once, not like highlight all occurrences of the text as we do in case of search. Answer You can use the jquery highlight effect. But if you are interested in raw javascript code, take a look
How to get start and end of day in Javascript?
How to get start ( 00:00:00 ) and end ( 23:59:59 ) of today in timestamp ( GMT )? Computer use a local time. Answer If you need to get the UTC time from those, you can use UTC().
How to create a function that converts a Number to a Bijective Hexavigesimal?
Maybe i am just not that good enough in math, but I am having a problem in converting a number into pure alphabetical Bijective Hexavigesimal just like how Microsoft Excel/OpenOffice Calc do it. Here is a version of my code but did not give me the output i needed: var toHexvg = function(a){ var x=”; var let=”_abcdefghijklmnopqrstuvwxyz”; var len=let.length; var
Detect if HTML5 Video element is playing [duplicate]
This question already has answers here: How to tell if a <video> element is currently playing? (7 answers) Closed 1 year ago. I’ve looked through a couple of questions to find out if an HTML5 element is playing, but can’t find the answer. I’ve looked at the W3 documentation and it has an event named “playing” but I can’t seem
Generic deep diff between two objects
I have two objects: oldObj and newObj. The data in oldObj was used to populate a form and newObj is the result of the user changing data in this form and submitting it. Both objects are deep, ie. they have properties that are objects or arrays of objects etc – they can be n levels deep, thus the diff algorithm
Javascript Named Function Expressions in Internet Explorer
Why does the following code not work in Internet Explorer (I’ve only tested in IE8 so far): If I change foo’s assignment to the following, the code works just fine: I imagine it’s something to do with named functions in IE’s Javascript engine. The code works fine in Chrome and Firefox. Any ideas? Answer IE has a lot of problems
How to start and stop/pause setInterval?
I’m trying to pause and then play a setInterval loop. After I have stopped the loop, the “start” button in my attempt doesn’t seem to work : Is there a working way to do this? Answer The reason you’re seeing this specific problem: JSFiddle wraps your code in a function, so start() is not defined in the global scope. Moral
Facebook Like button causing horizontal scrolling on mobile device
I have a Facebook Like button implementation which is rendering fine in all browsers desktop and mobile. But the issues lies on low-res devices with resolution of 240×320. the Like button is causing the device to zoom into the page thus rendering horizontal scrolling. The buttons is rendering fine on devices with width >= 320px like the iPhone etc., but
Make a number a percentage
What’s the best way to strip the “0.”XXX% off a number and make it a percentage? What happens if the number happens to be an int? Answer A percentage is just: No need for anything fancy: