Hi,
I am trying to make a simple text area code validation. Correct Code = advance , incorrect=try again
I want my users to see one text filed to fill out, titled "secret code". If they enter the correct code it redirects them to an internal page. If they enter an incorrect code they are put in a loop back to the form screen.
I have researched other posts on this forum. These two seem to be the closest to my problem.
https://www.chronoengine.com/forums/posts/f2/t100733/basic-code-check.html?page=1 - more than I need.
http://www.chronoengine.com/forums/posts/f2/t97068.html - CV4 not same admin interface.
Here is what I have tried so far ...
Layout
I created a form named : "test_ajax_code_check"
Created two elements : "Text Box" and "Submit Button"
Text Box Field Name : "code"
Text Box - Validation - Custom function : "checkCode"
Submit Button ( Nothing Changed from Default)
Setup
On Load
Load JavaScript :
Html Render (Nothing Changed)
On Submit
Event Switcher :
Events: "code"
Code:
** Not sure where else to put this code?
On Success : Email & Display Message
On Fail : Event Loop "load"
Here is a link where I am testing it out.
http://crackedtvstick.com/index.php?option=com_chronoforms5&chronoform=test_ajax_code_check
Don't know what else to try. I'm sure its simple and I'm just not getting but any help is greatly appreciated.
Thank you,
James
I am trying to make a simple text area code validation. Correct Code = advance , incorrect=try again
I want my users to see one text filed to fill out, titled "secret code". If they enter the correct code it redirects them to an internal page. If they enter an incorrect code they are put in a loop back to the form screen.
I have researched other posts on this forum. These two seem to be the closest to my problem.
https://www.chronoengine.com/forums/posts/f2/t100733/basic-code-check.html?page=1 - more than I need.
http://www.chronoengine.com/forums/posts/f2/t97068.html - CV4 not same admin interface.
Here is what I have tried so far ...
Layout
I created a form named : "test_ajax_code_check"
Created two elements : "Text Box" and "Submit Button"
Text Box Field Name : "code"
Text Box - Validation - Custom function : "checkCode"
Submit Button ( Nothing Changed from Default)
Setup
On Load
Load JavaScript :
function checkCode() {
var code;
code = jQuery('#code').val();
jQuery('#code').css('border-color', 'silver');
jQuery.ajax({
// send the code back to the server
url: 'index.php',
data: {
'option': 'com_chronoforms5',
'chronoform': 'test_ajax_code_check',
'event': 'ajax',
'tvout': 'ajax',
'code': code
}
})
// do this when data is received back
.done(function( data ) {
if ( data == 'invalid' ) {
jQuery('#code').val('');
jQuery('#code').css('border-color', 'red');
} else {
jQuery('#code').css('border-color', 'green');
jQuery('#code').prop('readonly', true);
}
});
}
Html Render (Nothing Changed)
On Submit
Event Switcher :
Events: "code"
Code:
<?php
$codes = array(
'apple',
'banana',
'orange',
'pear'
);
$reply = 'invalid';
if ( in_array($form->data['code'], $codes) ) {
// code is valid
$reply = 'valid';
}
echo $reply;
?>
** Not sure where else to put this code?
On Success : Email & Display Message
On Fail : Event Loop "load"
Here is a link where I am testing it out.
http://crackedtvstick.com/index.php?option=com_chronoforms5&chronoform=test_ajax_code_check
Don't know what else to try. I'm sure its simple and I'm just not getting but any help is greatly appreciated.
Thank you,
James