Posted By

Activetuts on 01/04/11


Tagged

url regexp validation web address as3


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

chus
liakwee
elderhsouza
dubogii


Validate a Web Address with RegExp


 / Published in: ActionScript 3
 

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

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

  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. }

Report this snippet  

You need to login to post a comment.