{"id":3394,"date":"2011-09-21T07:33:00","date_gmt":"2011-09-21T15:33:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=3394"},"modified":"2011-09-27T08:56:31","modified_gmt":"2011-09-27T16:56:31","slug":"primalforms-2011-validating-the-form-part-3","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/","title":{"rendered":"PrimalForms 2011: Validating the Form &#8211; Part 3"},"content":{"rendered":"<p>In <a href=\"http:\/\/www.sapien.com\/blog\/2011\/09\/09\/primalforms-2011-validating-the-form-part-2\/\">Part 2<\/a> we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation.  <\/p>\n<p><strong>Validating Techniques:<\/strong><\/p>\n<p><em><strong>Regular Expressions:<\/strong><\/em><\/p>\n<p>For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex data by providing formatting information. In addition, PowerShell has built in support for regular expressions in the form of the \u2013match operator. <\/p>\n<p>Example use of a regular expression in PowerShell:<\/p>\n<p><span style=\"color: #ff0000\">&#8220;PowerShell&#8221;<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-match<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #ff0000\">&#8220;shell&#8221;<\/span><\/p>\n<p>In this example we are matching any string that contains the word \u201cshell\u201d. <\/p>\n<p>We will not go into details on how to use Regular Expressions, since it\u2019s an extensive subject unto itself. We recommend referring to PowerShell\u2019s <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd315294.aspx\">about_Regular_Expressions<\/a> help topic or type \u201cPowerShell Regular Expressions\u201d in a search engine for more information.<\/p>\n<p><em><strong>Leverage PowerShell\u2019s Parameter Validation:<\/strong><\/em><\/p>\n<p>By using Parameter validation you can as validate TextBox values as well; although this isn\u2019t necessary the best method. For more information on Parameter Validation refer to the <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd347600.aspx\">about_functions_advanced_parameters<\/a> help topic.<\/p>\n<p><em>Validating Example 2 \u2013 Using Parameter Validation<\/em><\/p>\n<p>First, define a function that will use the function\u2019s Parameter Validation attributes:<\/p>\n<pre><span style=\"color: #0000ff\">function<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008080\">ParameterValidate<\/span><span style=\"color: #000000\"> \n{\n    <\/span><span style=\"color: #0000ff\">Param<\/span><span style=\"color: #000000\">(\n    [Parameter(Mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #8b0000\">$true<\/span><span style=\"color: #000000\">)]\n    [ValidateNotNull()]    \n    [ValidateLength(<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #000000\">10<\/span><span style=\"color: #000000\">)]\n    [String]<\/span><span style=\"color: #8b0000\">$Text<\/span><span style=\"color: #000000\">\n    )\n    <\/span><span style=\"color: #0000ff\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$true<\/span><span style=\"color: #000000\">\n}<\/span><\/pre>\n<p>Next modify the TextBox\u2019s Validating event:<\/p>\n<pre><span style=\"color: #8b0000\">$textboxName_Validating<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">[System.ComponentModel.CancelEventHandler]{\n    <\/span><span style=\"color: #008000\">#Init to False in case Validate Fails<\/span><span style=\"color: #000000\">\n    <\/span><span style=\"color: #8b0000\">$_<\/span><span style=\"color: #000000\">.Cancel <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$true<\/span><span style=\"color: #000000\">\n    <\/span><span style=\"color: #008000\">#Use Parameter Validation to Check TextBox value<\/span><span style=\"color: #000000\">\n    <\/span><span style=\"color: #0000ff\">try<\/span><span style=\"color: #000000\">{\n        <\/span><span style=\"color: #8b0000\">$_<\/span><span style=\"color: #000000\">.Cancel <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-not<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #008080\">ParameterValidate<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$textboxName<\/span><span style=\"color: #000000\">.Text)\n    }\n    <\/span><span style=\"color: #0000ff\">catch<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008000\">#Catch any Parameter Errors<\/span><span style=\"color: #000000\">\n    {    \n        <\/span><span style=\"color: #008000\">#$_ is now an Error in this scope<\/span><span style=\"color: #000000\">\n        <\/span><span style=\"color: #8b0000\">$errorprovider1<\/span><span style=\"color: #000000\">.SetError(<\/span><span style=\"color: #8b0000\">$textboxName<\/span><span style=\"color: #000000\">, [string]<\/span><span style=\"color: #8b0000\">$_<\/span><span style=\"color: #000000\">.Exception.Message);\n    }\n}<\/span><\/pre>\n<p>The resulting Error Message when the TextBox is empty:<\/p>\n<p><span style=\"color: #ff0000\">Cannot validate argument on parameter &#8216;Text&#8217;. The number of characters (0) in the argument is too small. Specify an argument whose length is greater than or equal to &#8220;1&#8221; and then try the command again.<\/span> <\/p>\n<p>As you can see this may not be the best error message to present to a user; therefore, you may have to customize your error messages.<\/p>\n<p><em><strong>Utilize the Appropriate Controls:<\/strong><\/em><\/p>\n<p>One can reduce the need to validate by using the appropriate controls for your data types:<\/p>\n<blockquote>\n<p><strong>DateTimePicker<\/strong> <\/p>\n<p>Use this control when you need a date or time. This control will inherently validate the date field for you; therefore, you need not parse the date or use regular expressions,<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong>MaskTextBox<\/strong><\/p>\n<p>Use this control when you need a phone number or other set format. The MaskTextBox insures the field is entered correctly by enforcing formatting. Depending on the format, you may still need custom validation for control or use the MaskTextBox\u2019s built in validation for DateTime formats and number values. See <a href=\"http:\/\/www.sapien.com\/blog\/2011\/09\/27\/primalforms-2011-spotlight-on-the-maskedtextbox-control\/\">PrimalForms 2011: Spotlight on the MaskedTextBox Control<\/a> blog article for more details.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong>ComboBox<\/strong><\/p>\n<p>Use this control when you have a predetermined set of values that the user must select from.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong>CheckBox<\/strong><\/p>\n<p>Use this control when you have yes or no type question.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong>NumericUpDown<\/strong><\/p>\n<p>Use this control when you have integer values. This control allows you to specify a range of valid values.<\/p>\n<p><strong>TextBox<\/strong><\/p>\n<p>Use this control when you have text information such as a name. If there is a size constraint on the data, then use the TextBox\u2019s the MaxLength property to limit the number of characters the user can enter. See <a href=\"http:\/\/www.sapien.com\/blog\/2011\/06\/13\/primalforms-2011-spotlight-on-the-textbox-control\/\">PrimalForms 2011: Spotlight on the TextBox Control<\/a> blog article for more details. <\/p>\n<\/blockquote>\n<p>Next: <a href=\"http:\/\/www.sapien.com\/blog\/2011\/09\/23\/primalforms-2011-validating-the-form-part-4\/\">Part 4<\/a> \u2013 How to trigger validation when the form is closing<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[509,575,25],"tags":[313,28,633,680,327],"class_list":["post-3394","post","type-post","status-publish","format-standard","hentry","category-primalforms-software-news","category-primalforms-2011-software-news","category-windows-powershell","tag-forms","tag-powershell","tag-primalforms-2011","tag-validation","tag-winform"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"David Corrales\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DEV SAPIEN Blog - Tools for IT Success\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-09-21T15:33:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2011-09-27T16:56:31+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#blogposting\",\"name\":\"PrimalForms 2011: Validating the Form \\u2013 Part 3 - DEV SAPIEN Blog\",\"headline\":\"PrimalForms 2011: Validating the Form &#8211; Part 3\",\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"},\"datePublished\":\"2011-09-21T07:33:00-07:00\",\"dateModified\":\"2011-09-27T08:56:31-07:00\",\"inLanguage\":\"en-US\",\"commentCount\":1,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#webpage\"},\"articleSection\":\"PrimalForms, PrimalForms 2011, Windows PowerShell, forms, powershell, PrimalForms 2011, Validation, WinForm\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"position\":2,\"name\":\"Software News\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalforms-software-news\\\/#listItem\",\"name\":\"PrimalForms\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalforms-software-news\\\/#listItem\",\"position\":3,\"name\":\"PrimalForms\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalforms-software-news\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#listItem\",\"name\":\"PrimalForms 2011: Validating the Form &#8211; Part 3\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#listItem\",\"position\":4,\"name\":\"PrimalForms 2011: Validating the Form &#8211; Part 3\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalforms-software-news\\\/#listItem\",\"name\":\"PrimalForms\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/\",\"name\":\"David Corrales\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#webpage\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/\",\"name\":\"PrimalForms 2011: Validating the Form \\u2013 Part 3 - DEV SAPIEN Blog\",\"description\":\"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2011\\\/09\\\/21\\\/primalforms-2011-validating-the-form-part-3\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/david-corrales\\\/#author\"},\"datePublished\":\"2011-09-21T07:33:00-07:00\",\"dateModified\":\"2011-09-27T08:56:31-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog","description":"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex","canonical_url":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#blogposting","name":"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog","headline":"PrimalForms 2011: Validating the Form &#8211; Part 3","author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"},"datePublished":"2011-09-21T07:33:00-07:00","dateModified":"2011-09-27T08:56:31-07:00","inLanguage":"en-US","commentCount":1,"mainEntityOfPage":{"@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#webpage"},"isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#webpage"},"articleSection":"PrimalForms, PrimalForms 2011, Windows PowerShell, forms, powershell, PrimalForms 2011, Validation, WinForm"},{"@type":"BreadcrumbList","@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dev.sapien.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","position":2,"name":"Software News","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/#listItem","name":"PrimalForms"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/#listItem","position":3,"name":"PrimalForms","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#listItem","name":"PrimalForms 2011: Validating the Form &#8211; Part 3"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#listItem","position":4,"name":"PrimalForms 2011: Validating the Form &#8211; Part 3","previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/#listItem","name":"PrimalForms"}}]},{"@type":"Organization","@id":"https:\/\/dev.sapien.com\/blog\/#organization","name":"DEV SAPIEN Blog","description":"Tools for IT Success","url":"https:\/\/dev.sapien.com\/blog\/"},{"@type":"Person","@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author","url":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/","name":"David Corrales"},{"@type":"WebPage","@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#webpage","url":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/","name":"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog","description":"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/#breadcrumblist"},"author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"creator":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/david-corrales\/#author"},"datePublished":"2011-09-21T07:33:00-07:00","dateModified":"2011-09-27T08:56:31-07:00"},{"@type":"WebSite","@id":"https:\/\/dev.sapien.com\/blog\/#website","url":"https:\/\/dev.sapien.com\/blog\/","name":"DEV SAPIEN Blog","description":"Tools for IT Success","inLanguage":"en-US","publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"DEV SAPIEN Blog - Tools for IT Success","og:type":"article","og:title":"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog","og:description":"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex","og:url":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/","article:published_time":"2011-09-21T15:33:00+00:00","article:modified_time":"2011-09-27T16:56:31+00:00","twitter:card":"summary_large_image","twitter:title":"PrimalForms 2011: Validating the Form \u2013 Part 3 - DEV SAPIEN Blog","twitter:description":"In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex"},"aioseo_meta_data":{"post_id":"3394","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-08-28 15:23:27","updated":"2026-08-28 15:23:27"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/\" title=\"Software News\">Software News<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/\" title=\"PrimalForms\">PrimalForms<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPrimalForms 2011: Validating the Form \u2013 Part 3\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dev.sapien.com\/blog"},{"label":"Software News","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/"},{"label":"PrimalForms","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalforms-software-news\/"},{"label":"PrimalForms 2011: Validating the Form &#8211; Part 3","link":"https:\/\/dev.sapien.com\/blog\/2011\/09\/21\/primalforms-2011-validating-the-form-part-3\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=3394"}],"version-history":[{"count":10,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3394\/revisions"}],"predecessor-version":[{"id":3481,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3394\/revisions\/3481"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=3394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=3394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=3394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}