Jump to content

Predefined input value


scferg

Recommended Posts

I was wondering, if it was possible to have predefined html form values. So, the form would only submit if the correct value was entered. Like, you need to enter "14" but you entered "13" ... the form would not submit. I just thought this would be a simple thing to do with javascript.

Link to comment
Share on other sites

Something like this:

 

function submitForm(){
    var val = document.getElementById('myField').value;
    if(val == 14){
        document.myForm.submit();
    }else{
        alert('Invalid Input');
    }
}

 

HTML:

<form name="myForm" action="page.php">
   <input id="myField" name="fieldName" />
   <input type="button value="Submit" onclick="submitForm();">
</form>

Link to comment
Share on other sites

Ok, I was using that as a type of CAPTCHA thing. I just needed something simple, but it was dumb of me to do it this way -- the bots have already gotten passed it. I've search all over the internet for a *real* CAPTCHA system, but all of them seem confusing. Like, some require databases and such. Do any of you know of a good CAPTCHA script, or know how to make one?

 

I really appreciate it ;)

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.