Skip to content Skip to sidebar Skip to footer

Html Form Required Command Not Working?

I'm trying to get my form to require certain fields be filled out before the form can be submitted. I searched and found that the command is supposed to be this simple command <

Solution 1:

The problem with your form isn't your html, it is your javascript.

On line 33 of config.js, you have the following line:

jQuery('form .form-button-submit').click(function(e) { e.preventDefault(); jQuery(this).closest('form').submit(); });

This line is preventing the default action of your submit button, bypassing the required attribute on your input element, and submitting the form. If you remove this line, I'm sure it will work.. Examples:

Your current method of form submission: http://jsfiddle.net/Daedalus/2FY9g/ <- does not work

Without the default action prevented: http://jsfiddle.net/Daedalus/2FY9g/1/ <- works

Solution 2:

i would use js to validate the entries a simple validate.js file that contains something like:

function validate username(){

var user = document.getElementsByName("username")[0];

if(user.value == "") return false; }

sorry about the formatting.. im new to this forum and still getting used to it :)

Solution 3:

Try this, add runat="server" to form......

<form id="form1" runat="server">

<input id="name" required />

<input type="submit" value="Search" />

</form>

Post a Comment for "Html Form Required Command Not Working?"