You can also use Mendix microflows and front end validation features.
If you want to use your scripts, you can include them in an HTMLSnippet and attach them to window or namespace them however you want.
To attach it to the keypress callbacks you can use something like this in an HTMLSnippet
try{
dojo.query(
'.mx-name-textBox1 input'//mbm widget attr, prefixed with .mx-name-
)[0]
.onkeyup=function(evt){
//process evt.target.value
//...
//set input node value
evt.target.value=processedvalue;
}
}catch(e){
console.error(e);
}