Thread: urgent help needed!!!
Results 1 to 2 of 2
Related
-
urgent xml / xsl help Forum: HTML Forum
Replies: 0 -
Need urgent help. Forum: HTML Forum
Replies: 0
-
05-07-2011, 01:38 PM #1
urgent help needed!!!
i have a assigment which has following details:
a html document with text area to accept integrs(-ve) also with comma and spaces allowed! when the input is submitted it should sort the results in reverse order on click!! the validiation shud be done in javascript for input!! plz help!! its really urgent.... i am a beginner to perl
-
08-24-2011, 06:51 PM #2
Re: urgent help needed!!!
Code:#! /usr/bin/perl use strict; use warnings FATAL => qw(all); use CGI::Carp qw(fatalsToBrowser); use CGI; ############################################################################### my $q = CGI->new; my $string = $q->param('string'); my @values; if ($string && $string =~ /^(\s*\d+\s*\,?\s*)*$/) { $string =~ s/\s+//g; @values = split /\,/, $string; @values = sort { $b <=> $a } @values; } ############################################################################### print $q->header; print <<'HTML'; <script type="text/javascript"> function validate() { var regex = /^(\s*\d+\s*\,?\s*)*$/ if (document.form.string.value.search(regex) == -1) alert("Validation failed.") else document.form.submit(); } </script> <form name="form" method="post"> HTML { local $" = ', '; print qq{<textarea name="string">@values</textarea>}; } print <<'HTML'; <input type="button" name="button" value="process..." onClick="validate()" /> </form> HTML ############################################################################### exit;
Last edited by xmassey; 08-24-2011 at 07:17 PM.
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum