I have form where user have to enter link and mail. Can someone please can write little script or tell me where to find javascript which check right format of mail and link
dunno. email:<br /> <input type="text" id="email" /><br /> homepage:<br /> <input type="text" id="url" /><br /> <br /> <input type="submit" id="check" value="check them" /> (function() { // create the string prototypes in a closed scope. var formVerifier = { regex: { email: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, // " url: /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i }, init: function() { String.prototype.isEmail = function() { // defer to parent by name because 'this' won't be available to prototype return this.match(formVerifier.regex.email); }; String.prototype.isURL = function() { return this.match(formVerifier.regex.url); }; } }; formVerifier.init(); })(); window.onload = function() { var fields = { email: document.getElementById("email"), homepage: document.getElementById("url") }; document.getElementById("check").onclick = function() { if (!fields.email.value.isEmail()) { alert(fields.email.value + " is not a valid email."); } if (!fields.homepage.value.isURL()) { alert(fields.homepage.value + " is not a valid url."); } }; }; PHP: the problem with url verification is ... its unreliable. you an do http://bar and that's valid. which technically CAN be valid if for example, using a host file aliasing or a local domain lookup etc. otherwise, you need to really look for a TLD that ends the url and this means knowing all acceptable TLDS which is a bummer to do, i suppose.