Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my application a Captcha is coming at after every 12 minutes. In this there is no such validation applied to avoid page refresh, so because of this when Captcha come on the screen and user refresh the page and then captcha disappear from the screen without filling the Captcha details into the textbox. Now i want when the captcha come on the screen, User Can't be able to refresh the page until he submitted the captcha.

Hereis my javascript for captcha

C#
function ShowNewPage() {
    var callbackFunctionArray = new Array(CloseCaptchaPopUp);
    modalWin.ShowURL('Captcha.aspx', 225, 290, 'Please enter characters dislayed in image to proceed', null, callbackFunctionArray);
}


Aspx Page code

XML
<div id="Popup_content">
        <div class="box1">
            <div class="popupheadrow">
                <p class="title">
                    Please enter text below:
                </p>
            </div>
            <div class="bodyrow" align="center">
                <div class="row" style="min-height: 18px">
                    <asp:Label ID="lblMessage" runat="server"  style="color:Green; font-size: 0.8em;" Text=" "></asp:Label>
                </div>
                <div class="row">
                    <asp:Image ID="Image1" runat="server" ImageUrl="CaptchaImage.aspx" Style="width: 255px" />
                </div>
                <div class="row">
                    <asp:TextBox ID="txtimgcode" runat="server" CssClass="fields" TabIndex="1" MaxLength="10"
                        AutoComplete="false"></asp:TextBox>
                </div>
                <div class="row">
                    <asp:Button ID="CaptchaSubmit" CssClass="submit" runat="server" OnClick="CaptchaSubmit_Click"
                        Text="Submit" Height="26px" />
                         <asp:Button style="display:none" id="btnHidden" runat="server" OnClick="btnHidden_Onclick" />
                </div>
            </div>
        </div>
        <script type="text/javascript">
            setInterval(function () { btnHidden.click(); }, 60000);
</script>
        <script type="text/javascript" language="javascript">
            function CloseCaptchaModalPopup() {
                window.parent.modalWin.CallCallingWindowFunction(0, 'Information Saved Scucessfully');
            }
        </script>
    </div>



Suggest me some solution How could i avoid Page refresh until user submitted the captcha.
Posted

You can validate the key press event to validate catch text box.


Disable F5
[^]


refer the above link. In the Keypress event of F5, if the captcha text box doesn't have the value then return false.

Let me know if this works for you.

Regards,
Maheswaran.S
 
Share this answer
 
v2
Comments
Member 10276989 5-Nov-14 2:54am    
But that will disabled F5 key from all pages.
How about making the f5 disable on captcha textbox focus ?

F5 Disable in document element focus
[^]

Try this . It will work for u. F5 will be disabled only if captcha appears in your page.


Regards,
Maheswaran.S
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900