Im new to powerbuilder:
I want to validate email text field after its done typing on it and go to another text field.
so I put my codes at "itemchanged event of the datawindow"
heres my code:
choose case dwo.name
case 'email'
if data <> '' then
if match(data,'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z][a-zA-Z][a-zA-Z]*[a-zA-Z]*$') then
else
This.SetText('')
MessageBox('Error', 'This is an invalid email')
end if
end if
end choose
What happens here is that when i type for example 'asd'.
So it is an invalid email becoz it does not pass the match
Its actually clears the email field but after the messagebox fired and I clicked OK.
'asd' value returns on email field which I had cleared.
I think that's weird?
Where event should I put my validation and how to code this? Or there is a code for this in itemchanged so that I can clear the email field?
Anybody who can help me?
Luckily I fixed it by doing this in dw
itemchangedevent.By adding
return 1it gives another message box.To override this default error message.
Add some chunk of codes at dw
itemerrorevent. :D