PHP Backend Joomla Form Validation
Form validation working on the input form in the front-end, but not working in the backend. Either doesn’t work or the form submits when it is not meant to.
You might have to change the toolbar buttons…
Put something like this above your code:
$html='<a class="toolbar" class="button validate" type="submit" onclick="javascript: return myValidate(adminForm);" href="#">
<span title="Apply" class="icon-32-apply"></span>Apply</a>';
JToolBarHelper::title(JTEXT::_('Edit Placement List'),'sections.png');
$bar = & JToolBar::getInstance('toolbar');
$bar->appendButton( 'Custom', $html);
<span title="Apply" class="icon-32-apply"></span>Apply</a>';
JToolBarHelper::title(JTEXT::_('Edit Placement List'),'sections.png');
$bar = & JToolBar::getInstance('toolbar');
$bar->appendButton( 'Custom', $html);
Or.. instead of usual script, replace it with the script:
<script language="javascript" type="text/javascript">
<!--
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancelemployer') {
document.adminForm.task.value = pressbutton;
form.submit();
}
if (document.formvalidator.isValid(form)) {
form.submit();
}
else {
alert('<?php echo JText::_('Fields highlighted in red are compulsory or unacceptable!'); ?>');
}
}
//-->
</script>
<!--
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancelemployer') {
document.adminForm.task.value = pressbutton;
form.submit();
}
if (document.formvalidator.isValid(form)) {
form.submit();
}
else {
alert('<?php echo JText::_('Fields highlighted in red are compulsory or unacceptable!'); ?>');
}
}
//-->
</script>
The task parameter must also be set when the form is valid and submitted. Below the
isValid()
function call.. you can put this:
form.task.value = pressbutton;