NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: terryd on August 31, 2015, 12:03:48 AM

Title: Set Focus back to Invalid entry field
Post by: terryd 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.
Title: Re: Set Focus back to Invalid entry field
Post by: Bruce 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
Title: Re: Set Focus back to Invalid entry field
Post by: terryd on August 31, 2015, 07:44:34 AM
It still sets focus to the next field
Title: Re: Set Focus back to Invalid entry field
Post by: walter.dasilva 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