Ciao,
I’m trying to use the InitScript property of a textbox which contain a decimal number but it doesn’t work.
I tried:
txtCosto.InitScript = “this.getChildControl(“”textfield””).setFilter(/^\d+(\,\d{1,2})?/);”
txtCosto.InitScript = “this.getChildControl(“”textfield””).setFilter(/^\d(\,\d)?/);”
It does not insert the comma.
Grazie
Alessandro
You can. But the filter property is also available in .NET https://docs.wisej.com/api/wisej.web/editors/wisej.web.textbox#filter
It filters the characters as they are typed. I.e.: a regex like [\d,] allows decimals and a comma.
It’s the same as this.getChildControl(“textfield”).setFilter(). For formatting the text you can format it when leaving the field. To mask it use the MaskedTextEditor. To validate on the server use the Validating event and the AutoValidate property on the container.
To validate on the client it’s a bit more complicated because you have to take some action on failed validation which can be anything: display something, keep the focus, collect the error text. Then there is the issue of localization. Then when and how to display, etc. Every application is different.
why can’t I use the InitScript property?
it’s more stylish and reusable!
Please login first to submit.