Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:32:21+00:00 2026-05-29T06:32:21+00:00

I have a working example of a form here . I need to use

  • 0

I have a working example of a form here. I need to use Javascript of Jquery form validation to verify that the user has inputted his/her own data. So far I have tried to check for values, but obviously this didn’t work, because the inputs and textarea already have a default value, and so the user can submit straight away without filling in anything.

Any help would be much appreciated.

Thanks in advance!

EDIT

I am using this php to send the submitted data to an email address:

<?php
$name = $_POST['name'];
if ($name=="") {
$name="Nothing was returned for this part of the form.";
}
$email = $_POST['email'];
if ($email=="") {
$email="Nothing was returned for this part of the form.";
}
$subject = $_POST['subject'];
if ($subject=="") {
$subject="Nothing was returned for this part of the form.";
}
$comments = $_POST['comments'];
if ($comments=="") {
$comments="Nothing was returned for this part of the form.";
}
$theMessage7="<b>Results from the form at www.site.co.uk/contact.html</b><br /><br />" . "Name:&nbsp;" . $name . "<br />" . "Email:&nbsp;" . $email . "<br />" . "Subject:&nbsp;" . $subject . "<br />" . "Message:&nbsp;" . $comments . "<br />";
$theEmail7="mail@mail.com";
$theSubject7="New form submission";
$theHeaders7="MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: form@bikeinc.co.uk
Subject: New form submission";
$theErrorFile7="www.site.co.uk/12345";
$theThanxFile7="received.html";
if (!(mail($theEmail7, stripslashes($theSubject7), stripslashes($theMessage7), stripslashes($theHeaders7)))) {
    header ( "Location: $theErrorFile7" );
        }else{
    header ( "Location: $theThanxFile7" );
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:32:21+00:00Added an answer on May 29, 2026 at 6:32 am

    The effective form of form validation on user side is to use jQuery validation plugin, see examples on proper usage.

    Note: user ALWAYS can disable javascript or use some kind of bot to send invalid not checked data, so you always have to write proper server side validation.

    Frameworks often provides effective way of form validation, such as Zend_Validator.

    It’s common to prepare method for your php application such as:

    public function validate() {
      if( !isset( $_POST['name'])){
        $this->field = 'name';
        $this->msg = 'Invalid user name';
        return false;
      }
    
      ...
      return true;
    }
    

    And use it in both sending script:

    if( $form->validate()){
      send();
    }
    

    And in check script:

    $data = array();
    if( $form->validate()){
      $data['status'] = 'ok';
    } else {
      $data['status'] = 'failure';
      $data['field'] = $form->field;
      $data['msg'] = $form->msg;
    }
    echo json_encode( $data);
    

    End than use jquery and javascript for form validation “on the fly”:

    <input type="text" name="name" value="" onchange="ajaxValidate();" />
    
    function ajaxValidate(){
      // Call ajax to check script and put results
    }
    

    If you’re just building small project with one form or so, you could implement few methods like:

    function is_post( $key); // Shorter than write isset( $_POST[ $key])
    function get_post( $key, $defaultValue); // Shorter than isset( $_POST[ $key]) ? $_POST[ $key] : $default
    function is_email(...); 
    ...
    

    And jQuery validation:

    function validateForm() {
      $('.input').removeClass( 'error');
      var status = true;
      if( $('input[name=name]').val() == '')){
         $('input[name=name]').addClass( 'error');
         setMessage( 'Name cannot be empty');
         status = false;
      }
    
      ...
    
      return status;
    }
    
    <form onsubmit='return validateForm();' ...>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on a web form that has repeating ui elements using the
I have a form that needs to be dynamic, allowing the user to add
I have a simple form that lists user names and for each user, the
Does anyone have a working example of a video player built using Qt phonon?
Does anybody have an example of working with database using Visual C++ and OLEDB?
I'm working through the NerdDinner ASP.NET MVC 1.0 example. I have it all working
I have this simple example I can't seems to get working : MERGE INTO
I am working through the examples in a Django book that I have, but
I have been working with a string[] array in C# that gets returned from
I am working on a FYI page that has large list of top-tiered links.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.