www.webdeveloper.com
Results 1 to 8 of 8

Thread: jcap security code and requirements

  1. #1
    Join Date
    Nov 2006
    Location
    Canyon Lake, TX
    Posts
    86

    Question jcap security code and requirements

    I have a basic form: name, email, comments, etc.
    I have gone into behaviors and validation and set the name to be required, the email to be required as an email etc.
    Upon submit, it pops-up and says you must fill out the required fields.
    And I got around the check box requied issue by putting a required text box instead of a checkbox.
    Yeah it works.

    see it in operation: www.keepitamerican.biz/GDform1.html

    NOW...

    I have implemented a jcap security code.
    It reads the javascript brings up a new image and requires the text to be correct before proceeding.
    Yeah it works.

    HOWEVER...

    my required name, email, accept terms text box - are no longer popping up as being required. You can now submit an empty form with just the jcap.

    see it in operation: www.keepitamerican.biz/GDform2.html

    MY QUESTION...

    Any idea how to get both to work together? You can see the code is still there for the required, is the jcap code over writing the DW code and if so - anyone know how to fix it?

  2. #2
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    Actually the DW code is never being executed. You're terminating the string on the onsubmit before it ever gets to the DW part. I think if you modify your onsubmit to the following:

    Code:
    onsubmit="return jcap() && MM_validateForm
    Insert two ampersands it'll work.
    Ryan Butler

    Ryan Butler.org

  3. #3
    Join Date
    Nov 2006
    Location
    Canyon Lake, TX
    Posts
    86

    Thank you and help

    Hi Ryanbuttler, the two ampersands worked!!!

    ...However I must me missing a step because after the box popped up and said the DW fields are required too and you press ok, it goes to the confirmation page immediately. I tried switching the code around to require the DW form then the jcap but upon ok of the popup box it went to the confirmation page without acknowledgement of even the jcap.

    So I switched it back to jcap fist then the DW but realize I must be missing a step in DW behaviors or something to keep it from going to the next page before anything is entered - but that even confuses me as the first form GDForm1.html did as it was supposed to. Any ideas?

  4. #4
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    Try:

    Code:
    onsubmit="return  jcap() && MM_validateForm('FirstName','','R','LastName','','R','email','','RisEmail','Agree','','R');return false; return document.MM_returnValue">
    You need to add a return false statement telling JS not to return true, since if the fields are empty, you need to fill in the rest of the fields before going to the submission page.
    Ryan Butler

    Ryan Butler.org

  5. #5
    Join Date
    Nov 2006
    Location
    Canyon Lake, TX
    Posts
    86

    Red face

    Hi Ryan,

    As much as I was REALLY hoping to be able to write back and say that did it! Because it seemed so simple... it must have been a bit too simple because it is still not operating properly. The return false; wasn't the whole answer.

    I am certain it has something to do with the JS coding DW put in the head but since I am not a coder, I can't find what it might be. The JS is put there by DW because of the behaviors right? Well on the Behaviors section I have three things:

    onSubmit: return jcap() && MM_validateForm('FirstName','','R','LastName','','R','email','','RisEmail','Agree','','R')
    onSubmit: return false
    onSubmit: return document.MM_returnValue

    Am I still missing a behavior? Or are they not in the right order? Or is there more required for the return false to operate?

    I also have 3 Hidden Fields within my form - they aren't causing the problem right?

    1) Subject of the email to be received
    2) uword (for the captcha image)
    3) Confirmation Page

    The 3rd one goes to the confirmation page... but I tried taking it off and adding a behavior onSubmit: Go To URL and it didn't work either so I put it back.

    Wow - you must be getting annoyed with me by now.

  6. #6
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    JS can be very trying at times. Alright, I scraped the DW nonsense (everything you mentioned regarding behaviors was correct) and wrote my own JS function, and then appended on the check to jcap at the end, all is working properly locally.

    Include this JS function in b/w the opening and closing <head> tags:

    Code:
    <script type="text/javascript">
    function checkme(){
    var message="Please complete the following:\n";
    var noerrors=message;
    
    if(document.contact.FirstName.value==""){
    	message+="Please enter your first name\n";
    }
    if(document.contact.LastName.value==""){
    	message+="Please enter your last name\n";
    }
    if(document.contact.email.value==""){
    	message+="Please enter your email name\n";
    }
    if(document.contact.Agree.value==""){
    	message+="Please enter your agree";
    }
    if(message==noerrors){
    return true;	
    }
    else{
    alert(message);	
    return false;
    }
    
    }
    </script>
    I don't know why you have text box for agreement, but that's another story.

    Change your opening form tag to this:

    Code:
    <form name="contact" action="gdform.asp" method="post" onsubmit="return checkme() && jcap();">
    That's it.
    Ryan Butler

    Ryan Butler.org

  7. #7
    Join Date
    Nov 2006
    Location
    Canyon Lake, TX
    Posts
    86

    Thumbs up

    Ryan you rule!

    Thank you so much for helping me through this! It works beautifully!

    But what gets me is that YOU had to write the JS to get the form to work properly when DW's OWN JS didn't do the job. It almost makes me say FrontPage ain't that bad after all. At least their forms worked. But I will use your JS and study it, and maybe down the line - as JS coding begins to make more sense to me - I'll be able to see what went wrong. What I do know is that JS is very finicky one coma where it shouldn't be and the whole thing won't work.

    On another note: you questioned my agree text box (instead of a check box) that was an issue in itself.

    DW allows you to 'require' text boxes & text areas but not check boxes or radio buttons - why? Why not give ALL of your options the ability to be required? I scoured the internet looking for solutions to the 'checkbox required' issue. I tried a JS I found, I set the checkedValue to required, I set behaviors, I even set a popup box to say you must check the box but (same issue as before) upon ok it would go to the confirmation page. So I got rid of the check box required and put a required text box in it's place. No extra JS needed, no extra behaviors needing to be set and instead of a simple click for the user they have to type yes or even Y - not a real hardship.

    Sometimes you just have to do what you have to do - right?

    Anyways, thank you again for 'putting up with me' and helping me get this -very simple task- solved. I really appreciate your time and patience.

    ~Kathleen

  8. #8
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    Quote Originally Posted by kathleen1357
    But what gets me is that YOU had to write the JS to get the form to work properly when DW's OWN JS didn't do the job.
    It would've done the job, I just couldn't figure out why adding a return false on the form tag wouldn't work...must have be within the code it wrote inside the head tags.

    It almost makes me say FrontPage ain't that bad after all. At least their forms worked.
    LOL, I wouldn't say that. FP stinks in my humble opinion.

    But I will use your JS and study it, and maybe down the line - as JS coding begins to make more sense to me - I'll be able to see what went wrong. What I do know is that JS is very finicky one coma where it shouldn't be and the whole thing won't work.
    JS is just as finicky as any other language. It just takes time to understand how it works in concert with other elements on the page.

    On another note: you questioned my agree text box (instead of a check box) that was an issue in itself.

    DW allows you to 'require' text boxes & text areas but not check boxes or radio buttons - why?
    I heard a reason one time, but I forgot. There used to be an extension that did it, but as I recall it didn't work right. It's not hard to add, simply add this to the existing script I wrote:

    Code:
    if(!document.contact.Agree.checked){
      message+="Please agree";
    }
    The exclamation is a boolean check, either the box is checked, meaning true or its not, meaning false.

    Anyways, thank you again for 'putting up with me' and helping me get this -very simple task- solved. I really appreciate your time and patience.
    You're welcome...anytime...it's a sense of community service for me.
    Ryan Butler

    Ryan Butler.org

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles