title: Best way to validate an IP address in Adobe Flex
body: <p>I'm trying to come up with the optimal solution for validating IP addresses in Adobe Flex.  My current solution is to use a regexp validator and look for dotted quad numbers, see code below.  For some reason this will also allow an address like "1.2.3.4.5".  Does anyone have a better solution out there?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"&gt;
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import mx.controls.Alert;
          ]]&gt;
      &lt;/fx:Script&gt;
      &lt;fx:Declarations&gt;
          &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
          &lt;mx:RegExpValidator source="{ipAddr}" property="text" 
                              expression="\d+\.\d+\.\d+\.\d+" 
                              invalid="Alert.show('The IP address is invalid');"/&gt;        
      &lt;/fx:Declarations&gt;
      &lt;s:TextInput id="ipAddr" x="10" y="10"/&gt;
      &lt;s:Button label="OK" x="10" y="40"/&gt;
  
  &lt;/s:Application&gt;
  </code></pre>