I looked around the forum but couldn't find this answer but sure it has been solved before....
Is there any sample code to validate a numeric form value.
For instance, I want the user to type in a number in the form and make sure the value is between 1 and 50.
Any suggestions?
Is there any sample code to validate a numeric form value.
For instance, I want the user to type in a number in the form and make sure the value is between 1 and 50.
Any suggestions?
Hi mruetz,
Yes, I think I posted this yesterday (but my memory could be failing).
Bob
Yes, I think I posted this yesterday (but my memory could be failing).
Bob
Yes, Bob posted this yesterday, please check for it.
Cheers
Max
Cheers
Max
I have been looking for it but haven't found it yet (using search and browsing as well). I will continue to look for it, but if anyone finds this thread, please post a link. Many thanks, Matt
Hi mruetz,
Well I can't find it either - I'll try again in the morning (or re-write it).
Bob
Well I can't find it either - I'll try again in the morning (or re-write it).
Bob
Try to make an advanced search and set the author to greyhead and look for his posts at 22,21,20 of this month ?
Hi mruetz,
Something like this added to your Form HTML (not the Javascript box)
Note : only the two script lines var field_id . . . and field_id.add do the validation. the rest is to load it correctly into the page.
Replace 'field_id' three times with the id of the field you want to validate; and set the max & min parameters.
Bob
Something like this added to your Form HTML (not the Javascript box)
<?php
$script = "
var field_id = new LiveValidation('field_id');
field_id.add( Validate.Length, {
minimum: 4,
maximum: 8
});
";
$script = "
window.addEvent('domready', function() {
$script
});
";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>Note : only the two script lines var field_id . . . and field_id.add do the validation. the rest is to load it correctly into the page.
Replace 'field_id' three times with the id of the field you want to validate; and set the max & min parameters.
Bob
Hi Bob,
How can I ensure a minimum value of 10.00 in a field.
--- edited later:
Found it:
Thanks!
How can I ensure a minimum value of 10.00 in a field.
--- edited later:
Found it:
<?php
$script = "
var text_0 = new LiveValidation('text_0');
text_0.add( Validate.Numericality, {
minimum: 10
});
";
$script = "
window.addEvent('domready', function() {
$script
});
";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>Thanks!
This topic is locked and no more replies can be posted.
