• Home
  • About
Blue Orange Green Pink Purple

Posts Tagged ‘forms’

You can use the search form below to go through the content and find a specific post or page:

Feb 05

Form Validation II

Continuing on from the first part of the tutorial, we are going to continue through the list of form elements in the order we setup. Next we work on the email address.

else if(document.getElementById(“email”).value==” ||
(
document.getElementById(“email”).value!=” &&
!
emailfilter.test(document.getElementById(“email”).value))){
document.getElementById(“error_msg”).childNodes[0].data=
‘Please enter a valid e-mail address.’;
document.getElementById(“error_msg”).style.display = “block”;
document.getElementById(“email”).focus();
return false;
}

Notice how we handle the email value checking first to see if it is empty to trigger an error and then using the logical operator OR (denoted as ||), we then look at another statement. In that statement we use the logical operator AND (denoted as &&) to trigger an error, and if both the email filed is not empty and the emailfilter.test is not valid then we do what is in between the curly brackets again. The contents are the same as what we described in the first statement.

Jan 30

client side form validation

The more we learn the more fun we have. Take for example the simple process of validating a form. We can save the user a lot of time validating the form on the client side and still do it without those annoying alerts that pop up with a loud DING! It is rather easy with the help of a little javascript.

Now depending on what type of data you are passing to the server with your form, you will often need to also validate your fields data on the server too. This tutorial will only look at the client side validation, leaving server side validation to another tutorial at some other time.

Lets first start with our form. We are going to do a simple form that just asks for name, email address, optional phone number, a select list for subject and text area for message. Oh, I always forget, we need a submit and clear button too. Lets start it all of with our form tag.

dingobytes

  • Most Popular
    550 Banned AJAX Apache Coldfusion css directives Directory effect failure form forms image Javascript message mouseover options rotator sendmail Service unavailable setup smtp auth turorial Tutorial validation VirtualHost web site
  • Archives
    • October 2008
    • August 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
  • flickrRSS probably needs to be setup
  • Archives
    • October 2008
    • August 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
  • Search






  • Home
  • About

© Copyright dingobytes. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top