Jump to content

how inactive submit button till user not fill the form?


noahwilson

Recommended Posts

You can do it with JavaScript - but that is no real guarantee that the user cannot submit the form until then. So, you definitely want server-side code to reject the submission if all the data is not there. You can, however, add JavaScript to add some client-side functionality to prevent 99% of submissions where the data isn't entered. But, you need to make a decision as to what you will do for users that don't have JS enabled. Do you not allow them to use the form at all or do you let them submit even though they may not have had the form completed. That will be key to how the solution is implemented.

Link to comment
Share on other sites

I am Agree with Psycho,nowadays javascript is used on large basis & on each & every sites.Below you can find a small code :

<html>
<head>
<title>Disable Form Example</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-latest.js'></script>
<script type='text/javascript'>
$(window).load(function(){
(function() {
    $('form > input').keyup(function() {

        var empty = false;
        $('form > input').each(function() {
            if ($(this).val() == '') {
                empty = true;
            }
        });

        if (empty) {
            $('#exinput').attr('disabled', 'disabled');
        } else {
            $('#exinput').removeAttr('disabled');
        }
    });
})()
}); 
</script>
</head>
<body>
  <form>
    Name<br />
    <input type="text"/><br />
	<input type="submit" id="exinput" value="Submit" disabled="disabled" />
</form> 
</body>
</html>


Hope it helps you! :happy-04:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.