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 8319991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:30:15+00:00 2026-06-08T22:30:15+00:00

So I have my form built in html and validated in JS and it

  • 0

So I have my form built in html and validated in JS and it does and looks the way I want. Now obviously I will be validating the input using PHP on the server side but I’m wondering if it would be secure enough to submit the form using Ajax and then validating on the server side, instead of submitting the form using a ‘submit’ type button and an ‘action’ attribute. Basically, is it safe to make server side validation dependent on the JS submitting it?

Here is my form:

<form name="contactForm" id="contactForm"><!-- The form has no action attribute because its submitted via Ajax -->
<div id="inputsWrapper">
    <div>
        <label for="fullName">Your Name: <span class="required">(required)</span></label>
        <input type="text" name="fullName" id="fullName" title="First &amp; last name" value="First &amp; last name" maxlength="50" />
    </div>
    <div>
        <label for="email">Your E-mail: <span class="required">(required)</span></label>
        <input type="text" name="email" id="email" title="E-mail address" value="E-mail address" maxlength="500" />
    </div>
    <div>
        <label for="subject">In Regards To: <span class="required">(required)</span></label>
        <input type="text" name="subject" id="subject" title="Subject" value="Subject" maxlength="50"/>
    </div>
    <div>
        <label for="message">Your Message: <span class="required">(required)</span></label>
        <textarea name="message" id="message" title="Enter your message here" cols="40" rows="10">Enter your message here</textarea>
    </div>
</div> <!-- End inputsWrapper -->
<input type="button" name="sendBtn" id="sendBtn" value="Send Message" /><!-- This button has a listener assigned to it in JS and submits the form on click -->

Once the button is clicked, the Ajax will submit the form via POST to my PHP script and either come back valid or not. Would this be a safe way of doing this or not? Thank you for any advice.

  • 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-06-08T22:30:17+00:00Added an answer on June 8, 2026 at 10:30 pm

    I’m wondering if it would be secure enough to submit the form using Ajax and then validating on the server side, instead of submitting the form using a ‘submit’ type button and an ‘action’ attribute.

    Yes. Input from outside the system is input from outside the system.

    Basically, is it safe to make server side validation dependent on the JS submitting it?

    Your JavaScript should be unobtrusive and implement progressive enhancement.

    The input to the script should be the same no matter if it came from a regular form submission of with Ajax (which is trivially easy if you use something like jQuery’s serialize), so there you shouldn’t need to make the server depend on the JS for the response.

    The only difference in how a form submission and an Ajax request is handled should be the formatting of the response.

    Either way, the data coming into the system is ultimately under the control of the submitter so you need to perform suitable sanity checking and escaping of it either way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to have the action of a HTML form built when the user
I have built a contact form using CakePHP on my site. The controller logic
I have to build an HTML Form with an Input text field for Hours
I have an html form which inserts data into a database. I just built
I am using MVC3 and I want to have LogIn form and Register form
I have built a zend form element for html content (general notes). class Sistema_Form_Note
I have a form built with formtastic, the code is <%= semantic_form_for @plan, :html
I have a simple html form. The built-in HTML helpers are rendering. The markup
I have a form I've built in PHP and storing the form field values
I have a multi-step order form built in this manner: Step 1: Choose category

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.