неделя, 16 септември 2007 г.

Regular expression for Javascript emai validation

You can validate email using following expression.

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

This script is used by asp.net email validators

четвъртък, 2 август 2007 г.

Opening new windows with Javascript

You'll notice in the previous example there is no way to control if the menubar, toolbar, statusbar, or linkbar, or scrollbars are visible. You also can't control whether the window is resizable either.

You can control these settings if you use javascript to open a window instead. You would use the window.open(url, name, parameters) javascript method. This just opens a basic window, but there are a bunch of other attributes you can set to control how this window looks. Below, you'll find a list of the most commonly used attributes:

url - The url string to be diplayed in the window. This setting is optional for when you want to write content to the window depending on user input. More on this later.

name - The unique name string given to a window. This value can be used for target attributes for links. If this value is not unique, any other windows created with the same name will replace this window.

parameters - Comma seperated string of parameters. There should be no spaces in this list. Any parameters left out will be displayed by default. Basic format is parameter1=value1,parameter2=value2,etc.... If the parameter is specified, but no value is assigned, it will default to yes (This rules does not apply to parameters that need values such as width, height, etc).

height - Height of the content of the window in pixels. This does not include menubar/statusbar.

width - Width of the content of the window in pixels.

menubar - Specifies if the menubar (File, Edit, View, etc) is displayed. yes or no.

scrollbars - Specifies if the scrollbars are displayed. yes or no.

toolbar - Specifies if the button images (back, forward, reload, stop, etc) bar is displayed. yes or no.

status - Specifies if the status bar is displayed. yes or no.

left (use screenX for Netscape 4) - The horizontal window position in pixels from the left of your monitor screen.

top (use screenY for Netscape 4) - The vertical window position in pixels from the top of your monitor screen.

resizable - Specifies if the window is resizable. yes or no. Watch for spelling, many people mistankingly use "resizeable" instead, which will not work.




url - The URL of the page to open. Example: "http://scriptasylum.com".

w - The width of the window in pixels.

h - The height of the window in pixels (doesn't include menubars).

tb - Toolbar visible? 1 = yes, 0 = no.

stb - Status bar visible? 1 = yes, 0 = no.

L - Linkbar visible? 1 = yes, 0 = no.

mb - Menubar visible? 1 = yes, 0 = no.

sb - Scrollbars visible? 1 = yes, 0 = no.

rs - Resizable window? 1 = yes, 0 = no.

x - The horizontal position of the window from the left of the screen.

y - The vertical position of the window from the top of the screen.