Hi I currently have a form on submission the following validation rule is checked:
<script language="JavaScript">
var frmvalidator = new Validator("contactform");
frmvalidator.addValidation("message","req","Please enter a valid message.");
</script>
function Validator(frmname)
{
this.formobj=document.forms[frmname];
if(!this.formobj)
{
alert("Error: couldnot get Form object "+frmname);
return;
}
if(this.formobj.onsubmit)
{
this.formobj.old_onsubmit = this.formobj.onsubmit;
this.formobj.onsubmit=null;
}
else
{
this.formobj.old_onsubmit = null;
}
this.formobj._sfm_form_name=frmname;
this.formobj.onsubmit=form_submit_handler;
this.addValidation = add_validation;
this.setAddnlValidationFunction=set_addnl_vfunction;
this.clearAllValidations = clear_all_validations;
this.disable_validations = false;//new
document.error_disp_handler = new sfm_ErrorDisplayHandler();
this.EnableOnPageErrorDisplay=validator_enable_OPED;
this.EnableOnPageErrorDisplaySingleBox=validator_enable_OPED_SB;
this.show_errors_together=true;
this.EnableMsgsTogether=sfm_enable_show_msgs_together;
document.set_focus_onerror=true;
this.EnableFocusOnError=sfm_validator_enable_focus;
}
However I would like the error message to be displayed on the webpage rather than an alert, could someone please achieve this.
The tutorial you are using cites the form validator as http://www.javascript-coder.com/html-form/javascript-form-validation.phtml If you read that, specifically at the top of the second page you will see:
The text which follows this provides further options for handling of error messages.
You could perhaps try that.