For Loop in JavaScript

A JavaScript for loop takes the parameters initialisation, condition and loop end expression. The parameters conditions and expressions associated with the for loop are wrapped within brackets. for(var i = 0; i < parameters.length; i++) { repeated action here } The example shown above, may be used to work through each of the entries in […]

Read More… from For Loop in JavaScript

Block Right Mouse Click

Clicking on the right mouse button can be disabled using JavaScript. It is also possible to be more selective, blocking the right click on specific items. The simplest method to disable the mouse right click on a website is through the use of a JavaScript function, acting on the document context: <script type=”text/javascript”> document.oncontextmenu = […]

Read More… from Block Right Mouse Click

JavaScript Timeout

JavaScripts timeout allows a preset delay before a function is called. Timeouts in JavaScript can be used to create a repeat, for example to slide a div, creating a scrolling marquee effect. The timeout is based on the setTimout() method. setTimout() can take two parameters, the first can be a function reference and the second […]

Read More… from JavaScript Timeout

Email Address Validation

Regular expressions can be used with JavaScript to validate a form email address entry. The function below accepts a form and performs the text on the textbox field with the ID of Email. function validateEmail(frmAddress) { //Validating the email field var rgxp = /^(([^<>()[\]\\.,;:\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,}))$/ if (! frmAddress.Email.value.match(rgxp)) { alert(“Invalid email address”); frmAddress.Email.focus(); frmAddress.Email.select(); return (false); […]

Read More… from Email Address Validation