I believe I am getting closer, muddling my way through an unfamiliar scripting language....but no luck yet
original code that checked for valid email:
window.addEvent('domready', function() {
// set the url to send the request to
var url =
'index.php?option=com_chronoforms&chronoform=VehicleSubmissionMobile&event=ajax&format=raw';
var unique_id = $('unique_id');
unique_id.addEvent('blur', function() {
// clear any background color from the input
unique_id.setStyle('background-color', 'white');
// check that the email address is valid
regex = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i;
var value = email.value.trim();
if ( value.length > 6 && regex.test(value) ) {
// if all is well send the JSON request
var request = new Request({
method: 'post',
url: url,
data: { 'unique_id' : value },
onComplete: function(r) {
// check the result and set the background color
if ( r == 'ok' ) {
unique_id.setStyle('background-color', 'green');
} else {
unique_id.setStyle('background-color', 'red');
}
} }).send();
} else {
// if this isn't a valid unique_id set background color red
unique_id.setStyle('background-color', 'red');
}
}); });
current code:
window.addEvent('domready', function() {
// set the url to send the request to
var url =
'index.php?option=com_chronoforms&chronoform=VehicleSubmissionMobile&event=ajax&format=raw';
var unique_id = $('unique_id');
unique_id.addEvent('blur', function() {
// clear any background color from the input
unique_id.setStyle('background-color', 'white');
// if all is well send the JSON request
var request = new Request({
method: 'post',
url: url,
data: { 'unique_id' : value },
onComplete: function(r) {
// check the result and set the background color
if ( r == 'ok' ) {
unique_id.setStyle('background-color', 'green');
} else {
unique_id.setStyle('background-color', 'red');
}
} }).send();
}); });