diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm
index 8573145af..6b70bd0fa 100644
--- a/lib/WebGUI/Form.pm
+++ b/lib/WebGUI/Form.pm
@@ -44,6 +44,7 @@ Base forms package. Eliminates some of the normal code work that goes along with
$html = WebGUI::Form::file({name=>"image"});
$html = WebGUI::Form::formHeader();
$html = WebGUI::Form::filterContent({value=>"javascript"});
+ $html = WebGUI::Form::float({name=>"distance"});
$html = WebGUI::Form::group({name=>"groupToPost"});
$html = WebGUI::Form::hidden({name=>"wid",value=>"55"});
$html = WebGUI::Form::hiddenList({name=>"wid",value=>"55",options=>\%options});
@@ -542,6 +543,58 @@ sub formHeader {
}
+
+#-------------------------------------------------------------------
+
+=head2 float ( hashRef )
+
+Returns an floating point field.
+
+=over
+
+=item name
+
+The name field for this form element.
+
+=item value
+
+The default value for this form element.
+
+=item maxlength
+
+The maximum number of characters to allow in this form element. Defaults to 11.
+
+=item extras
+
+If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows:
+
+ 'onChange="this.form.submit()"'
+
+=item size
+
+The number of characters wide this form element should be. There should be no reason for anyone to specify this.
+
+=back
+
+=cut
+
+sub float {
+ my $value = $_[0]->{value} || 0;
+ my $size = $_[0]->{size} || 11;
+ my $output = '';
+ $output .= text({
+ name=>$_[0]->{name},
+ value=>$value,
+ size=>$size,
+ extras=>'onKeyUp="doFloatCheck(this.form.'.$_[0]->{name}.')" '.$_[0]->{extras},
+ maxlength=>$_[0]->{maxlength}
+ });
+ return $output;
+}
+
+
+
+
#-------------------------------------------------------------------
=head2 group ( hashRef ] )
@@ -843,23 +896,12 @@ sub integer {
my ($output, $size, $value);
$value = $_[0]->{value} || 0;
$size = $_[0]->{size} || 11;
- $output = '';
+ $output = '';
$output .= text({
name=>$_[0]->{name},
value=>$value,
size=>$size,
- extras=>'onKeyUp="doNumCheck(this.form.'.$_[0]->{name}.')"'.$_[0]->{extras},
+ extras=>'onKeyUp="doNumCheck(this.form.'.$_[0]->{name}.')" '.$_[0]->{extras},
maxlength=>$_[0]->{maxlength}
});
return $output;
diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm
index a93c53ec6..f42b2e1b4 100644
--- a/lib/WebGUI/HTMLForm.pm
+++ b/lib/WebGUI/HTMLForm.pm
@@ -44,6 +44,7 @@ Package that makes HTML forms typed data and significantly reduces the code need
$f->fieldType("dataType",\%supportedTypes,"Type of Field");
$f->file("image","Image to Upload");
$f->filterContent("filterThisContent","Filter This Content");
+ $f->float("distance","5.1");
$f->group("groupToPost","Who can post?");
$f->hidden("wid","55");
$f->HTMLArea("description","Description");
@@ -661,6 +662,78 @@ sub filterContent {
}
+#-------------------------------------------------------------------
+
+=head2 float ( name [ label, value, maxlength, extras, subtext, size, uiLevel ] )
+
+Adds an integer row to this form.
+
+=over
+
+=item name
+
+The name field for this form element.
+
+=item label
+
+The left column label for this form row.
+
+=item value
+
+The default value for this form element.
+
+=item maxlength
+
+The maximum number of characters to allow in this form element. Defaults to 11.
+
+=item extras
+
+If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows:
+
+ 'onChange="this.form.submit()"'
+
+=item subtext
+
+Extra text to describe this form element or to provide special instructions.
+
+=item size
+
+The number of characters wide this form element should be. There should be no reason for anyone to specify this.
+
+=item uiLevel
+
+The UI level for this field. See the WebGUI developer's site for details. Defaults to "0".
+
+=back
+
+=cut
+
+sub float {
+ my ($output);
+ my ($self, @p) = @_;
+ my ($name, $label, $value, $maxlength, $extras, $subtext, $size, $uiLevel) =
+ rearrange([qw(name label value maxlength extras subtext size uiLevel)], @p);
+ if (_uiLevelChecksOut($uiLevel)) {
+ $output = WebGUI::Form::float({
+ "name"=>$name,
+ "value"=>$value,
+ "maxlength"=>$maxlength,
+ "size"=>$size,
+ "extras"=>$extras
+ });
+ $output .= _subtext($subtext);
+ $output = $self->_tableFormRow($label,$output);
+ } else {
+ $output = WebGUI::Form::hidden({
+ "name"=>$name,
+ "value"=>$value
+ });
+ }
+ $self->{_data} .= $output;
+}
+
+
+
#-------------------------------------------------------------------
=head2 group ( name [ label, value, size, multiple, extras, subtext, uiLevel, excludeGroups ] )
diff --git a/www/extras/floatCheck.js b/www/extras/floatCheck.js
new file mode 100644
index 000000000..78167de70
--- /dev/null
+++ b/www/extras/floatCheck.js
@@ -0,0 +1,21 @@
+function doFloatCheck(field) {
+ var valid = "0123456789"
+ var ok = "yes";
+ var points = 0;
+ var temp;
+ for (var i=0; i 1) ok = "no";
+ if (ok == "no") {
+ field.value = field.value.substring(0, (field.value.length) - 1);
+ }
+}
+
diff --git a/www/extras/numberCheck.js b/www/extras/numberCheck.js
new file mode 100644
index 000000000..6a5c345ce
--- /dev/null
+++ b/www/extras/numberCheck.js
@@ -0,0 +1,13 @@
+function doNumCheck(field) {
+ var valid = "0123456789"
+ var ok = "yes";
+ var temp;
+ for (var i=0; i