I think you have two options:
1) Create a validator that prepends 0s to single digit numbers. The problem is this will also change the value that is visible to the user.
2) Modify your code generators to prepend 0s to single digit numbers.
For 1 you would need to add code like:
```
Blockly.Blocks['my_block'] = {
init: function() {
this.appendDummyInput("RHS_INPUT")
.appendField(new Blockly.FieldTextInput("value", this.validate), "value");
},
validate: function(val) {
if (!isNaN(val) && val.length == 1) { // If the value is a single digit number.
return '0' + val;
}
return val; // Not necessary, but makes the validator clear.
}
}
```
For 2 you would need to add code like:
```
Blockly.JavaScript['my_block'] = function(block) {
var text_value = block.getFieldValue('NAME');
if (!isNaN(text_value) && text_value.length == 1) { // If the value is a single digit number.
text_value = '0' + text_value;
}
/// assembled and return code string...
};
```
Note that this code hasn't been tested! But I think it should work.
I hope that helps :D
--Beka