I have to make a textfield as invalid. I tried the following code. But it alerts as ‘valid’.
name.markInvalid('Error');
if (name.isValid()) {
alert('valid');
}
Any help is must appreciated..thankz
You really need to read the API docs about this. The Field get marked visually invalid but it will not test nor run the validation functions. So if you run it after that the field may surely be valid if the validation don’t fail. If you want it to be totally invalid apply a validation rule that the field will never pass after the markInvalid() call. Maybe the simples t way is a custom validator that always returns false.
Edit: API link fixed