So, I have my form embedded in html and validated in JS, and it does and looks the way I want. Now, obviously, I will check the input using PHP on the server side, but I wonder if it will be safe enough to send the form using Ajax, and then check on the server side instead of sending the form using the type "send" and the attribute " act". Basically, is it safe to perform server side validation based on JS submission?
Here is my form:
<form name="contactForm" id="contactForm"> <div id="inputsWrapper"> <div> <label for="fullName">Your Name: <span class="required">(required)</span></label> <input type="text" name="fullName" id="fullName" title="First & last name" value="First & 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> <input type="button" name="sendBtn" id="sendBtn" value="Send Message" />
After clicking the button, Ajax will submit the form via POST to my PHP script and will either come back or come back. Would this be a safe way to do this or not? Thanks for any advice.
source share