0
Answered

Example to check value in Edit-field

Theo Derks - NL (distributor) 8 years ago in Applications / Studio (Server editor) updated by Aleksandr Romanov (CTO) 8 years ago 3

Hello

Is there anybody who has an example to validate the content of an Edit-box:

- For example: the value has to be between 50 and 100

- Or the length of the entered value has to be < 5 digits

- Etc


Thanks!


Theo


+1

//This one checks to see if the value in the edit box is >= 0 or <= 255


 IR.AddListener(IR.EVENT_ITEM_CHANGE,IR.GetItem(Mullions_G1).GetItem("R 1"), function() {    
 var edtText = IR.GetItem(Mullions_G1).GetItem("R 1").Text;      
if(edtText.Text !=''){
IR.Log("edtText " + edtText)
if(edtText >= 255) { //set the edit box text back to 255
IR.GetItem(Mullions_G1).GetItem("R 1").Text = "255"
}
if (edtText <= 0){ //set the edit box text back to 0
IR.GetItem(Mullions_G1).GetItem("R 1").Text = "0"
}
}
});