NetTalk Central

Author Topic: Set Focus back to Invalid entry field  (Read 3960 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Set Focus back to Invalid entry field
« on: August 31, 2015, 12:03:48 AM »
In a website I have a field that after entry is validated checking for length, numeric only etc.
If the validation passes I want it to go to the next field. Although it wasn't necessary I put the equate of the next field into the When accepted, Set Focus field.
The validation works. If it finds an error the Entry field clears, an alert message pops up but the focus jumps to the next field.
Is there a way to set focus back to the entry field if certain criteria fail in the validation routine.
This happens when Save is clicked so I am hoping to be able to hijack the method.
This is not such a problem in normal web mode since the alert pops up but in mobile the alert message doesn't show and it moves to the next field so probably the first time that the user realises that the field wasn't accepted is when he clicks save.
« Last Edit: August 31, 2015, 12:06:56 AM by terryd »
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Set Focus back to Invalid entry field
« Reply #1 on: August 31, 2015, 07:19:52 AM »
>> Although it wasn't necessary I put the equate of the next field into the When accepted, Set Focus field.

what happens if you remove this?

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Set Focus back to Invalid entry field
« Reply #2 on: August 31, 2015, 07:44:34 AM »
It still sets focus to the next field
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

walter.dasilva

  • Sr. Member
  • ****
  • Posts: 314
  • SOFTVALE
    • MSN Messenger - walter@softvale.com.br
    • View Profile
    • SOFTVALE
Re: Set Focus back to Invalid entry field
« Reply #3 on: December 07, 2015, 06:18:28 AM »
If condiction=false
  Loc:invalid = 'fieldname'
  Loc:alert = 'message'
  p_web.SetValue('SelectField',clip(loc:formname)&'.'&p_web.NoColon('Fieldforfocus'))
END

!extract from Validation example
! here's an example of disabling the Save button if this field is invalid, or
! enabling it if it is valid.
if loc:Invalid
  p_web.Script('$("#'& clip(loc:FormName)&'").ntform("disableSave");')
else
  p_web.Script('$("#'& clip(loc:FormName)&'").ntform("enableSave");')
end
Walter - SOFTVALE