% my $url = $opt{'post_url'} || popurl(1)."process/$table.html";
+% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform', 'errormessage' => 'Please only numeric characters ' } };
<FORM NAME = "edit_topform"
METHOD = POST
ACTION = "<% $url %>"
% $include_common{'layer_prefix'} = "$field$fieldnum."
% if $layer_prefix_on;
%
+% ## set conditionname field values for validation.
+% if ($field eq 'conditionname') {
+% my $validate_field = $field . $fieldnum . '.after_event.run_delay';
+% $js_form_validate->{edit_topform}{$validate_field} = 'numeric';
+% }
+%
% my @include =
% ( "/elements/$include.html",
% 'field' => "$field$fieldnum",
: $opt{'html_foot'}
%>
- <% include("/elements/footer.html") %>
+% my %footerdata = (
+% 'formvalidation' => $js_form_validate,
+% );
+
+ <% include("/elements/footer.html", %footerdata) %>
% }
<%init>
|| [ grep { $_ ne $pkey } fields($table) ];
#my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
+my $js_form_validate = {};
+
my( $mode, $object);
my $clone = '';
if ( $opt{'embed'} ) {
};
} elsif ( $info->{'type'} eq 'freq' ) {
$value = '0' if !length($value) and !$info->{'allow_blank'};
+ $value = '0' if $value =~ /[^\d]/;
$value .= $params->{$cgi_field.'_units'} if length($value);
}
</TD>
</TR>
</TABLE>
+
+% if ($opt{'formvalidation'}) {
+% my $form_validation = $opt{'formvalidation'};
+% foreach my $name (sort keys $form_validation) {
+% my $form = $form_validation->{$name};
+ <script>
+ var validator = new FormValidator('<% $name %>', [
+% foreach my $field (sort keys $form) {
+ {
+ name: '<% $field %>',
+ rules: 'numeric'
+ },
+% }
+ ],
+ function(errors) {
+ if (errors.length > 0) {
+ for (var i = 0; i<= errors.length; i++) {
+ alert ('<% $form_validation->{$name}->{errormessage} %>');
+ //alert ('<% $form_validation->{$name}->{errormessage} %>' + errors[i].message);
+ return false;
+ }
+ }
+ return true;
+ }
+ );
+ </script>
+% }
+% }
+
</BODY>
</HTML>
+
+<%init>
+
+my(%opt) = @_;
+
+</%init>
\ No newline at end of file