Bogiecom.com
  • About
  • Magento
  • Sitecore
  • WordPress

Magento Custom Form Field Validators using Prototype (MySQL Date Format)

Posted on November 9, 2011 by bc-admin

Here I needed to make sure that the user input was formatted correctly for a MySQL database. The javascript calendar code was set to automatically input the date into the text field in the correct format, but the user still had the option to type it in manually. This was the Prototype validator I used to verify that the user had entered it correctly as ‘YYYY-MM-DD’:

1
2
3
4
5
<script type="text/javascript">
  Validation.add('required-date-format','Please Enter date as YYYY-MM-DD. Click the calendar icon to select a date.', function(v) {
       return  !Validation.get('IsEmpty').test(v) && /^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])$/.test(v);  });
       var warrantyregistrationForm = new VarienForm('warrantyregistrationForm', true);
</script>

Posted in Custom Field Validator, Date Format, Magento, MySQL |
« Check out this great MSN Video: Air Force to launch ‘mini’ shuttle
Grooveshark Konami Code »

Pages

  • About
  • Magento
  • Sitecore
  • WordPress

Archives

  • January 2017
  • December 2013
  • November 2013
  • February 2013
  • January 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • November 2011
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009

Categories

  • .NET
  • Air Force
  • Apache Configuration
  • Bash
  • C#
  • Comma-Delimited
  • Custom Field Validator
  • Date Format
  • Dump Files
  • Files
  • Grep
  • Grooveshark
  • HTML
  • Image Resizing
  • Imagick
  • Integration
  • jQuery
  • Konami Code
  • Linux
  • Magento
  • Magento Third Party CMS Integration
  • Mini Shuttle
  • Miva Merchant 5.5
  • MySQL
  • PHP
  • Powershell
  • Regular Expressions
  • Rename-Item
  • Sed
  • Shell Scripting
  • Sitecore
  • Strings
  • Uncategorized
  • Updating Product Attributes
  • Video Games
  • Wordpress
  • X-37
  • XML
  • YUI Konami Event

CyberChimps WordPress Themes

© 2008 - 2016 Bogiecom.com