Monday, July 28, 2014

My Javascript Way to Check the Validity of an Email Address Input

Before sending an email address input from a submitted form to the server to verify, it is better to perform a simple check on the email address format for any possible typo. This will save some server bandwidth as Javascript is capable of catching some obvious email format errors. The following Javascript codes/function are used: <script> function emailError() {  if (document.userForm.em.value.match(/(\w+\@\w+\.\w+)/) == null) {   return true;  }  return...
Read More »

Sunday, July 27, 2014

Javascript to Disable Mouse Scroll for All Browsers including IE

I use these codes to temporarily disable the mouse scroll when I display a pop-up DIV. Although this is not quite necessary but it looks more professional to have mouse scroll locked when the pop-up appears. However the side scroll bar is still working with these following codes. You can still use the mouse to drag the page upward or downward. The following javascript codes/functions are used: (to lock mouse scroll only that uses the center wheel of a mouse) <script> var...
Read More »

Saturday, July 26, 2014

Javascript Way to Check Loaded Image

I use this to display images only after they are loaded into the browser's memory. I need Javascript codes to tell me if the image is ready to be displayed or processed. For example, there is a huge image that I need to display but the size is too big. I display a loading icon before I reveal the image so that it looks more like a contemporary (jQuery equipped) web page. I use the following Javascript codes. <script> var loaded_img = new Array(); var image_list = new Array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg");...
Read More »

Wednesday, July 23, 2014

IE4-7 Jagged Text Problem After Applying Filter and the Solution

IE4 until IE7 is notorious to have this anti-alias being turned off after applying a filter to a text (with the position property is set to absolute) such as the opacity filter used for fade in and fade out. For example, the following HTML codes will show the jagged text (without anti-alias) after even applying an empty filter in IE7: <span id="test" style="position:absolute;top:10px;left:10px;">Remove...
Read More »