You can easily validate a TextBox against a phone number format, in JavaScript, using Regular Expressions (RegEx): <script type=“text/javascript”> function FormValidate(){ if(document.Form1.PhoneNumber.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1) { alert(“The phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx.”); return false; } } </script> And the HTML markup that works with this script, is: <form […]
Clipboard cut, copy and paste with JavaScript
This tutorial will show you how to copy text to the clipboard, cut to the clipboard and paste, all these from a browser window.
A list of keys and the JavaScript char codes they correspond to
This table is especially useful for those who want to capture the key press event in the browser window. These are the char codes JavaScript uses, and the keys they bind to: Char Key Name 8 Backspace 9 Tab 13 Enter 16 Shift 17 Ctrl 18 Alt 19 Pause 20 Caps Lock 27 Escape 33 […]
How do I make a JavaScript function wait before executing (sleep / delay)?
You’ll need to enclose the code that you want to execute after the delay in a function (Func1()). This function will then be called with a delay, in our case from another function (Func1Delay()). Then you simply call Func1Delay() which in turn calls Func1() but with a delay of 3000 milliseconds (3 seconds):
Get key press event using JavaScript
This tutorial will show you how to get the pressed key in the browser window, whether it’s Ctrl, Alt, Shift, Page Up, Arrow Up or any other key. There’s both an Internet Explorer and a Firefox way of doing this.
Using radio buttons with JavaScript
This tutorial will show how to make a textbox display a text depending on which radio button was checked.
Creating a Rich Text Editor using JavaScript
This tutorial will explain how to create a rich text editor in a webpage using simply an iFrame in editable mode and its methods.
Dynamic 5 Star Rating Script
A dynamic 5 star rating script that can be used along with a server-side language and AJAX to allow visitors to submit their vote in an interactive manner.
OOP in JavaScript: Introduction
An introduction to Object Oriented Programming in Javascript. This example creates a small user control that can be used repeatedly and independantly on the same web page.
An introduction to JavaScript
An introduction to JavaScript, how it was born, what is it good for, different types and versions of this scripting language, and the compatibility between it and the browsers.