Jump to content

Display Errors at top of page


smti

Recommended Posts

Hello,

 

I wrote a validation script for a form I created. Currently when an error occurs, the error is displayed just below the submit button (at the bottom of the page). Does anyone have any ideas on how I can display the errors at the top? Here is my code:

 

if (strlen($doa) < 10){
$errors['doa'] = 'Invalid Admission Date!';
echo $errors['doa'];
$errorcount=$errorcount+1;
}

 

Let me know if you need more background information.

 

Thank You,

 

smti

Link to comment
Share on other sites

Hello,

 

I'm not sure if that would work or not. Here is how my code is setup:

 

<b>A.</b> Form is setup to submit to self. A "hidden" value checks to see if form has been submitted, if it has, the validation file is included:

 

if (submitted==1){

include("../processing/processcase.php");
validdatecase(); 

 

<b>B.</b> Inside the validation function the code looks something like this:

if (strlen($doa) < 10){
$errors['doa'] = 'Invalid Admission Date!';
echo $errors['doa'];
$errorcount=$errorcount+1;
}

 

Since the error is outputted inside each if statement, I am not sure that simply moving the error code to the top would work. If anyone has any thoughts on how to achieve the same ends using different means, please do not hesitate to say so.

 

<b>C.</b> If all fields are valid, addcase() is called (Within the same file as the validation).

 

- smti

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.