Admun's Tech Journey

thoughts, ideas, projects, and discoveries on technologies

  • Main
  • Tag Cloud
  • Archives

11

Jun

Check Date in Javascript

Posted by Admun  Tags: javascript, tips, date
I was looking for a way to validate date in javascript the other day.... this is what I came up with. It takes advantage from Date() that returns empty object if an invalidate date is passed to it.

Not sure if there's a better way?


/* var from is a date in string format "10/30/2010 03:44:12" */
var timeFrom = new Date(from);
var fromMonth = from.substring(0,2) - 0;
var fromDay = from.substring(3,5) - 0;
var fromYear = from.substring(6,10) - 0;
if (timeFrom.getMonth()+1 != fromMonth || timeFrom.getDate() != fromDay || timeFrom.getFullYear() != fromYear) {
$("div#error").text('Please enter a valid date range.');
}
Leave a comment

07

Jun

Turn off A tag Action in HTML

Posted by Admun  Tags: javascript, html, tips
I use it often but never seem to remember it, so it'd be good to document here somewhere. cool


<a class="action doSomething" id="777" onclick="javascript:return false;" href="#">


Once the link click is disabled, a javascript/jQuery script can hook to this tag and do its work. ie A background AJAX call, popup, etc.
Leave a comment

About Me

admun My passion has always been on software development, and I know it since I wrote my first program on an Apple II. I worked on cellular wireless system in the past (C/C++) and now focus on web application (LAMP, PHP, MySQL, CakePHP, Symfony, jQuery, Google AppEngine/python).

Tags

abit android apache app engine audio bandwidth benchmark bing blogroll bluetooth boinc bookmark botnet bt cakephp cdma cellphone chinese chrome clouds coding crash crawler date dns drm dsl fedora friendster g1 gaim gdesklets gmail google grid h323 hardware html ie6 instant messaging internet javascript jquery language lifestreaming linux liunx meetup ming motorola msi mysql nas nat networking nokia ntp nucleus opinion optimization os p2p palm parrot php power reblog redhat regex rss sdk se search security shell skype social network spam stats string svn syntax sysadmin t-mobile teksavvy telecom thinkpad time tips tuning tv twitter unix voip web web app web2.0 webos wordpress

Archives

  • Full archive
  • May, 2013
  • Feb, 2013
  • May, 2012
  • Aug, 2011

Search

Powered by LMNucleus CMS v3.66 | Copyright Edmond Hui
This page takes 0.036 sec/27 queries to process | NP_BadBehavior blocked 334 spams for the past 7 days
Theme Design by short funny jokes | Ported to Nucleus CMS by BABOCHTA
[Valid XHTML 1.0 Strict]