11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

validations[0]=["document.myform.username", "notblank"];<br />

validations[1]=["document.myform.useremail", "validemail"];<br />

validations[2]=["document.myform.favoritenumber", "isnumber"];<br />

// Customize above array when used with a new page.<br />

function isEmpty(s)<br />

{<br />

}<br />

if (s == null || s.length == 0)<br />

return true;<br />

// <strong>The</strong> test returns true if there is at least one non-<br />

// whitespace, meaning the string is not empty. If the<br />

// test returns true, the string is empty.<br />

return !/\S/.test(s);<br />

function looksLikeEmail(field)<br />

{<br />

var s = field.value;<br />

if (isEmpty(s))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!