# onDataChange returns false but allows to loose focus

**URL:** <https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439>\
**Category:** Classic Servoy\
**Created:** [July 5, 2010, 3:03am UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439 "2010-07-05T03:03:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maria](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@maria](https://forum.servoy.com/u/maria)\
**Post date:** [July 5, 2010, 3:03am UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439/1 "2010-07-05T03:03:42Z")

</div>

Hi All!

onDataChange event returns false (my validation method), colors the field contents in red and would not allow me to tab out of the field.  
However, the user can click other elements on the form like ‘save’ or ‘search’ buttons with the mouse - that will allow them to get away leaving the wrong value in the field and even save data.

Is it the expected behaviour or a bug?  
I’ve tried to put a validation method in onFocusLost and return the focus to the field with elements[elementName].requestFocus() in case of a failed validation.  
But it still allows me to click on the buttons that will save the data. The buttons are on the same form as the field.

Cheers,  
Maria

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [July 5, 2010, 1:00pm UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439/2 "2010-07-05T13:00:01Z")

</div>

Maria,

Which version of Servoy is this?  
And are you using webclient or smartclient?

Rob

---

<div class="post-metadata">

**Author:** ![maria](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@maria](https://forum.servoy.com/u/maria)\
**Post date:** [July 6, 2010, 3:10am UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439/3 "2010-07-06T03:10:02Z")

</div>

> rgansevles:  
> Maria,
> 
> Which version of Servoy is this?  
> And are you using webclient or smartclient?
> 
> Rob

Hi Rob,

It’s Servoy Version: 5.1.4 - build 964 and I’m using the Smart Client.

Cheers,  
Maria

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [July 6, 2010, 6:40am UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439/4 "2010-07-06T06:40:20Z")

</div>

Maria,

This is not expected behaviour.  
I could not reproduce this in a small test.  
Please create a case in our support system, attach a sample solution that shows this.

[http://servoy.com/s](http://servoy.com/s)

Rob

---

<div class="post-metadata">

**Author:** ![maria](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@maria](https://forum.servoy.com/u/maria)\
**Post date:** [July 7, 2010, 5:44am UTC](https://forum.servoy.com/t/ondatachange-returns-false-but-allows-to-loose-focus/12439/5 "2010-07-07T05:44:53Z")

</div>

> rgansevles:  
> Maria,
> 
> This is not expected behaviour.  
> I could not reproduce this in a small test.  
> Please create a case in our support system, attach a sample solution that shows this.
> 
> [http://servoy.com/s](http://servoy.com/s)
> 
> Rob

Thanks Rob.  
I’m having trouble reproducing the behaviour in a sample solution, will see what I can do about it.

Cheers,  
Maria
