diff options
Diffstat (limited to 'gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Captcha.html')
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Captcha.html | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Captcha.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Captcha.html new file mode 100644 index 0000000..971e9c6 --- /dev/null +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/Captcha.html @@ -0,0 +1,73 @@ +{% load i18n %} +{% load ndf_tags %} + + +<div class = "row"> + <div class = "medium-3 column" id = "captcha-content" > + <!-- Area to append captcha --> + </div> + + <br> + + <div class = "medium-4 column" ends> + <label class='fi-refresh js-captcha-refresh'> </button> + </div> + +</div> +<div class = "invalid-captcha"> + +</div> +<script type="text/javascript"> + + var formData = []; + $('form').submit(function(event){ + event.preventDefault(); + + $('form').find("input[name]").each(function (index, node) { + formData.push(String(node.name) + ":"+ String(node.value)); + }); + + $.ajax({ + url: "{% url 'captcha_validate' %}", + type:"POST", + data:{ + formData, + csrfmiddlewaretoken: '{{ csrf_token }}'}, + success:function(data) + { if (data == 'True') + { //Diconnect the on Submit action from form + $('form').off("submit") + //Trigger the submit action manually + $('form').submit() + } + else + { $('.invalid-captcha').empty(); + $('.invalid-captcha').append("<labe style = 'color:red;'> invalid captcha Try Again !! </label>") + } + } + }); + }); + + $(document).ready(function(){ + get_new_captcha(); + }); + + + function get_new_captcha(){ + $.ajax({ + url:"{% url 'new_captcha' %}", + type:"GET", + success:function(data) + { + $('#captcha-content').empty() + $('#captcha-content').append(data) + } + }); + } + + $('.js-captcha-refresh').click(function(){ + get_new_captcha(); + }); + + +</script>
\ No newline at end of file |