Validate a Web Address with RegExp


/ Published in: ActionScript 3
Save to your folder(s)

From the tutorial, Validating Various Input Data in Flash (http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/)


Copy this code and paste it in your HTML
  1. public function checkWebAddress(address:String):Boolean
  2. {
  3. var protocol:String = "(https?:\/\/|ftp:\/\/)?";
  4. var domainName:String = "([a-z0-9.-]{2,})";
  5. var domainExt:String = "([a-z]{2,6})";
  6. var web:RegExp = new RegExp('^' + protocol + '?' + domainName + "\." + domainExt + '$', "i");
  7.  
  8. return web.test(address);
  9. }

URL: http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.