Blog posts

  • Validation with regular expressions: Allow two formats

    Here's a nice piece of regular expression submitted by Nils that allow validation against two different formats, in this case 10 or 12 numbers:
    ^[0-9]{10}(?: [0-9]{2})?$

  • Actionscript: How to check if a variable is undefined?

    September 10, 2009 | Tags: Actionscript, AS3, Flash, Snippet
    As null isn't the same thing as having a variable undefined. How then do you check if it's defined or not? Well, here's the answer:
    if(!myVariable) {
    trace("it's not defined");

  • ASP.NET: Regular expression validator for e-mail address

    September 09, 2009 | Tags: ASP.NET, Validation, Snippet
    A snippet for using the RegularExpressionValidator to validate if form field holds a correct e-mail address:
    <asp:RegularExpressionValidator ControlToValidate=
    "EmailField" ValidationExpression=
    "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Text="*"
    ErrorMessage="Not a valid e-mail address" runat="server" />

  • Changed rotated dynamic textfield dissapears and how to solve it

    March 20, 2009 | Tags: Actionscript, AS3, Troubleshooting, Flash
    Text in Flash is a very special chapter. Static textfields works well, but once you begin to change the text dynamicly at runtime anything could happen. I recently wanted to change the text in a dynamic textfield that was slightly rotated. The text that was entered in the Flash IDE appeared as it should but once changed the textfield dissapeared completely.

    After some searching I found a couple of pages that suggested it could be a font embed problem. has some good info on that. But the problem remained since I used "Anti-alias for readability" and had the font embedded.

    Then the solution to an older problem struck me. I had prior had trouble with keeping the font format while changing the text. Appearently things like letter spacing etc is removed once the new text is set. The solution to this is to store away the font format, change the text and then set the font format back. I tested if that could be the case also for rotated text and it was!
    import flash.text.TextFormat;

    var tf:TextFormat = txtHeader.getTextFormat();
    txtHeader.text = "MY NEW TEXT";

  • ASP.NET: Client side validation don't work in Firefox (and solution)

    February 12, 2009 | Tags: ASP.NET, Troubleshooting
    Today we noticed a curious bug in a web application we're working on. The client side validation (RequiredField validator etc) worked perfectly fine in Internet Explorer, but not at all in Firefox! My first reaction was to check for javascript errors as they tend to prevent other functions to run properly. The error console was empty.

    What it turned out to be is the way ASP.NET renders XHTML. This is controlled within the web.config:
    <xhtmlconformance mode="Legacy"/>
    Our problem was that the automaticly generated line said Legacy, what actually means ASP.NET 1.1 compatible. As we uses strict XHTML 1.0 a better choice would be:
    <xhtmlconformance mode="Strict"/>
    And then, lo and behold, after changing mode to Strict the client side validation worked perfectly in Firefox!!

    More about xhtmlConformance: