コントロールまたはダイアログの検証を要求するために使用されるプロシージャです。
説明
{let md:MessageDisplay = {MessageDisplay}}
{let a:TextField =
{TextField
message-display = md,
{validate-with {NumericValidator}, required? = true}
}
}
{on Action at cb:CommandButton do
{if {validate-dialog {non-null cb.dialog}} then
{popup-message "go!"}
}
}
{TextField
name = name,
{bind value to name},
{validate-with {StringValidator}, required? = true},
{on vc:ValidationComplete at tf:TextField do
{if vc.current? and not vc.partial? and tf.valid? then
{tf.update-data-binding "value"}
}
}
}
プログラミング注意事項
| 例 | |
![]() | |
{let md:MessageDisplay = {MessageDisplay}}
{let low-field:TextField =
{TextField
{validate-with
{NumericValidator}, required? = true
}
}
}
{let high-field:TextField =
{TextField
{validate-with
{NumericValidator}, required? = true,
message = "High is required and must be a number."
}
}
}
{let go-button:CommandButton =
{CommandButton
label = "&Go",
{on Action do
{popup-message "Go!"}
}
}
}
{Dialog
message-display = md,
margin = 6pt,
{VBox
spacing = 6pt, width = 2.5in,
{bold Low must be <= high},
{Table columns = 2,
"Low:", low-field,
"High:", high-field
},
md,
go-button
},
{validate-with {DialogValidator}},
{on ve:Validate at d:Dialog do
let domain:Domain = {StandardIntDomain}
{try
let h:int = {domain.parse high-field.value}
let l:int = {domain.parse low-field.value}
{if l > h then
{d.mark-invalid
message =
{text Low should be less than or equal to High}
}
}
catch ex:ValidationException do
|| Do nothing, NumericValidator will report errors
}
},
{on vc:ValidationComplete at d:Dialog do
set go-button.enabled? = d.valid?
{md.show vc, d}
}
}
|