Textfiled input error alert in Sproutcore

123 Views Asked by At

There are some text fields in my Sproutcore code. However, I need to check the input validation for the text field.

Are there any mechanisms which I can do that like in traditional html/js? Could you please attach some code? Thanks.

Currently I just use the alert().

1

There are 1 best solutions below

1
On BEST ANSWER

Assuming you're using SC.TextFieldView, you can use Validator. Here is an example:

SC.TextFieldView.design({              
  validator: 'Number', 
  maxLength: 20,
}),

You can create your own validators to feet your needs. For examples and documentation, take a look at :

sproutcore/frameworks/foundation/validators