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
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
Mobile Dev World

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 : Validating a URL with JavaScript RegExp
Categories : Java Script, Data Validation, Beginner Guides
Boaz Yahav
Date : Sep 24th 2005
Grade : 5 of 5 (graded 3 times)
Viewed : 49342
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

The next code checks the following :

o URL starts with a-z, A-Z (e.g. http, ftp...)
o It is then followed by ://
o next we have more letters, numbers and special chars : a-z, A-Z, 0-9, -, _
o there must be at least one "."
o A URL can contain at it's end part the more special characters and this is
why the last part allows for more options such as ?, /, &, %, etc...
you may add/remove chars as needed to your code.


<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Validate(form) {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!v.test(form["URL"].value)) {
        alert("You must supply a valid URL.");
        return false;
    }
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="MyForm" ACTION="MyFile.php" METHOD="POST" onSubmit="return Validate(this);">
<INPUT TYPE="TEXT" NAME="URL" VALUE="http://">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT">
</FORM>
</BODY>
</HTML>



Form Processing : with alert Highlight field name which is not filled by user
Categories : Java Script, Form Processing, Data Validation, Beginner Guides, Web Design
Show and Hide Tables, Table Rows, Form Elements Etc.
Categories : Java Script, Beginner Guides
Form Validation Using PHP to highlight non valid fields
Categories : PHP, Form Processing, Data Validation, Beginner Guides
Conditional Check - a script that allows a user to submit a form only if the user check a checkbox.
Categories : HTML, Java Script, Form Processing, Beginner Guides
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
Ajax - Perform a simple server side request and update the current HTML page.
Categories : AJAX, Java Script, Beginner Guides
Adding a Filter to a Text Element
Categories : Java Script, Data Validation, Form Processing
Changing the Style of form objects using the JavaScript OnClick method.
Categories : Java Script, Form Processing, Beginner Guides, CSS
A function to clean input coming from form fields (Minimize the risk for XSS and SQL Injection attacks).
Categories : Beginner Guides, Security, Data Validation
Show hide table rows to make dynamic forms
Categories : Beginner Guides, Java Script, Form Processing, HTTP
JavaScript dropdown list menu to switch any page.
Categories : Java Script, Beginner Guides, Form Processing
Local Time clock and Server time usign PHP and JavaScript
Categories : PHP, Java Script, Date Time, Beginner Guides
Get your browser details using javascript
Categories : Java Script, Beginner Guides, Browsers
Store, retrieve and delete cookies using JavaScript.
Categories : Java Script, Cookies, Beginner Guides, Cookies
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides