You cannot do this directly through XML. However, you can create a custom block, set the css validation class there and use it as a type in widget.xml.
Application / code / local / Mynamespace / MyModule / etc. /widget.xml:
<somefield> <required>1</required> <visible>1</visible> <label>Some number</label> <type>mynamespace_mymodule/element_numeric</type> </somefield>
Application / code / local / Mynamespace / MyModule / block / element / Numeric.php:
class Mynamespace_Mymodule_Block_Element_Numeric extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element { public function render(Varien_Data_Form_Element_Abstract $element) { $element->setType('text'); $element->addClass('validate-digits'); parent::render($element); } }
It is important that the custom element block extend the Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element class so that it displays correctly in the field set.
source share