Form validation

nate100

Member
I need to do a check on if field 1 - field 6 are blank, I need to have the user re-enter these fields. The form has 30 fields altogether.
What is the best way to have the user go back to the form and re-enter these values.
One idea as to have teh following:

miniloop:
repeat:
if (field1 = "" AND field2 = "") OR (field3 = "" and field4 = "") OR (field5 "" and field6 = "")THEN DO:
message "Please update the info correctly".
update sitef sitet routef routet devpcf devpct deppcf deppct with frame a.
if (field1 = "" AND field2 = "") OR (field3 = "" and field4 = "") OR (field5 = "" and field6 = "") then next miniloop. else leave.
end. /* if (field1 = "" ..... */
end. /* repeat */

I am looking for something that would be easier or more standard in terms of approach. For example, for single field validation, I can do next-prompt, what is the solution for multiple fields like in my situation.

Thanks
 
You could use a function and some trigger conditions.

Of course, you could put as many validations as you want into the function.


Code:
def var field1 as char no-undo.
def var field2 as char no-undo.
def var field3 as char no-undo.
def var field4 as char no-undo.
def var field5 as char no-undo.
def var field6 as char no-undo.
def var field7 as char no-undo.
def var field8 as char no-undo.
def var field9 as char no-undo.
def var field10 as char no-undo.
 
session:data-entry-return = yes.
form 
  field1 field2 field3 field4 field5 field6 field7 field8 field9 field10 with frame f1.
 
function f_validate_ok returns logical (inp_handle as widget-handle):
  def var fieldok as logical initial yes no-undo.
  do with frame f1:
    case inp_handle:name:
      when "field2" then do:
        if field1:screen-value = "" and field2:screen-value = "" then fieldok = no.
      end.
      when "field4" then do:
        if field3:screen-value = "" and field4:screen-value = "" then fieldok = no.
      end.
      when "field6" then do:
        if field5:screen-value = "" and field6:screen-value = "" then fieldok = no.
      end.
    end case.
  end.
  return fieldok.
end function.
 
on leave, return, value-changed of field1, field2, field3, field4, field5, field6, field7, field8, field9, field10 in frame f1 do:
  if f_validate_ok (self:handle) = no then do:
    message "Please update the info correctly" view-as alert-box error.
    return no-apply.
  end. 
end.
update field1 field2 field3 field4 field5 field6 field7 field8 field9 field10 with frame f1.
 
Back
Top