1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Contact Form Validation

Discussion in 'HTML & Website Design' started by espressobeanmachine, Jan 16, 2017.

  1. #1
    So I got this form with javascript validation but how can I properly kickback a message from the php to the javascript to display either the success or error message without turning the whole page into a php one?

    Test Link:


    HTML Source:

    PHP Source:

    espressobeanmachine, Jan 16, 2017 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    FROM PHP requires AJAX, but really if your page is big enough to be wasting that level of scripttardery on such a SHORT form, with all those endless idiotic data attributes slopped all over the place -- there's something criminally wrong with whatever page you're slopping all that scripttardery into.

    My advice, axe all the JS for nothing, use the modern HTML 5 attributes for client side validation, but write the PHP as if client side validation SIMPLY DOESN'T EVEN EXIST!

    Oh noes, a page load where you have to spit the populated form back at the user if they make a mistake, NOTS THATZIES!!!

    when you are WASTING 5.45k of HTML and scripting on doing the job of 1k or LESS, you're not making it more useful to users.

    ... and that's before we talk the requirement of the idiotic "how not to write JavaScript" that is jQuery, the equalily idiotic dumbass use of what I assume is bootcrap, lack of ID's for the labels to target, lack of FOR attribute on the labels to created their semantic associations, lack of a proper fieldset...

    If I were writing that same contact form, I would likely not be using significantly more code than:

    <form id="signup" method="post" action="processing.php">
    		<label for=">Username</label>
    		<label for="signup_email">Email address</label>
    		<label for="signup_password">Password</label>
    	<div id="submitsAndHiddens">
    		<input type="submit" value="Submit">
    		<input type="reset" value="Reset">
    		<input type="hidden" name="hash" value="serverGeneratedHashHere">
    	<!-- #submitsAndHiddens --></div>
    Code (markup):
    Losing the captcha for a session hash, and not wasting my time with bloated useless broken scripting rubbish. Since you ALWAYS need to validate server side anyways, it doesn't validate you just spit it back at the user populated with what they already typed and messages. That introduces any REAL server load or causes any usability issues, there's something disastrously wrong with the rest of the site...

    Like the fat bloated idiotic dumbass halfwit bullshit that is jQuery, or the desperate need to go find a stick to scrape that bootcrap off with, scripting only captcha flipping the bird at accessibility and graceful degradation, and generally telling large swaths of users to go shtup themselves. What you have there is a poster child for why the web becomes less and less useful to users as developers just sleaze together off the shelf parts any old way, and why we're seeing a financial and bandwidth crunch as these stupid scripttard "oh it looks cleaner" crap just makes pages slower and harder to use!
    deathshadow, Jan 17, 2017 IP
    mmerlinn likes this.