WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Form validations using javascript and including all validations in one message
Categories : HTML and PHP, Java Script, Form Processing Click here to Update Your Picture
stuti patel
Date : Nov 01st 2007
Grade : 4 of 5 (graded 2 times)
Viewed : 2006
File : 4711.zip
Images : No Images for this code example.
Search : More code by stuti patel
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

It describes the type of form validations for textboxes, emails, select type using javascript and using only one alert nmessage to view all validations

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form Validations</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--code-->
<script>
function Required(element, description, type)
{
    this.element = element;
    this.description = description;
    this.type = type;
}

function textOK(e) { return (e.value != "") ? true : false; }

function selectOK(e) { return (e.options[e.selectedIndex].text != "-Select-") ? true : false; }

function emailOK(e)
{
    var at = e.value.indexOf('@');
    var dot = e.value.lastIndexOf('.');
    var space = e.value.indexOf(' ');
    var len = e.value.length - 1;

    return ((at > 1) && (dot >= at + 1) && (dot < len) && (space  == -1)) ? true : false;
}


function isReady(f)
{
    //alert("in");
    var r = new Object();
    r[0] = new Required(f.gender, "Gender", "select");
    r[1] = new Required(f.fname, "First Name", "text");
    r[2] = new Required(f.lname, "Last Name", "text");
    r[3] = new Required(f.email, "Email Address", "email");
   
    var msg = "";
    for (var i in r)
    {
        if ((r[i].type == "text" && !textOK(r[i].element)) ||
            (r[i].type == "email" && !emailOK(r[i].element))||
            (r[i].type == "select" && !selectOK(r[i].element)))
        {   
            msg += "- " + r[i].description + "\n"; 
        }
    }
   
    var msg1 = "";
    var mChecked = false;
       
    if (mChecked == false) {
        msg = msg + msg1;
    }       
    if (msg.length > 0)
    {
        msg = "Either You omitted the following required field(s) \n Or Information You Provided is Incorrect :\n\n" + msg;
        msg += "\nPlease complete the form and submit it again."
        alert(msg);
        return false;
    }

    return true;
}
//--></script>         
<!--/code-->       
</head>
<body>
<table width="100%">
<form name="frm" onSubmit="return isReady(this);" method="post">
<tr><td valign="top">Gender: <select name="gender"><option value="-Select-">-Select-</option><option value="m">Male</option><option value="f">Female</option></select></td></tr>
<tr><td valign="top">FirstName: <input type="text" name="fname"></td></tr>
<tr><td valign="top">LastName: <input type="text" name="lname"></td></tr>
<tr><td valign="top">Email: <input type="text" name="email"></td></tr>
<tr><td valign="top"><input type="submit" name="btnsubmit" value="Submit"></td></tr>
</form>
</table>
</body>
</html>



Sed, a coder's best friend. This lovely linux command allows you to swap strings in a file. Great for changing a variable name in a script with multiple files.
Categories : HTML and PHP, HTML and PHP
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
showing Help (assistance) to the user while filling html forms.
Categories : HTML, Java Script, Form Processing
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
Javascript URL and Email Validation
Categories : Java Script, Data Validation, Form Processing, Email, URLs
Sql Builder
Categories : PHP, HTML and PHP, Databases, General SQL, Form Processing
Hilight Form Element onFocus
Categories : Java Script, Form Processing, CSS
Simple POST and GET example
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
Dynamic form field
Categories : PHP, HTML and PHP, Form Processing
Form Processing : with alert Highlight field name which is not filled by user
Categories : Java Script, Form Processing, Data Validation, Beginner Guides, Web Design
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
Adding a Filter to a Text Element
Categories : Java Script, Data Validation, Form Processing
 El Sayed Othman wrote :1728
I'll use it from now ON .. thanQ :)