Category Archives: Java Script

Java Script Tutorials

Validate email address using Javascript

You can use following regular expressions to validate email function validateEmail(email) { var re = /^(([^()[\]\\.,;:\s@\”]+(\.[^()[\]\\.,;:\s@\”]+)*)|(\ “.+\”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA -Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }

Using window.onerror How to Catch Unhandled Errors in Javascript

Client side scripting language Javascript has an event driven error handling model where you define a handler function for window.onerror to override the error handling. This method has three arguments error message, url and line number. It should return true … Continue reading

Get File Name using Javascript : ASP.NET FileUpload Control

Many of C# developers looking for getting filename at client side. Following is the solution for that. <%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”upload.aspx.cs” Inherits=”UploadImagePreview.upload” %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”> <html xmlns=””> <head runat=”server”> <title></title> <script type=”text/javascript”> function … Continue reading

Calculate date difference using Javascript

Calculating date difference in JavaScript is very easy as in .Net, Java or PHP, but requires a bit different approach. For this post i wrote simple example which can calculate difference between two dates in: days and months. you can … Continue reading