For the life of me, what am I missing? I have tried to load custom functions in a form and then use those to reformat/update fields in the form.
To start, I have a simple script that changes text to proper-case. I place the function inside the Custom javascript Content, and I have tried Add inside domready as well.
The function shows up in the source code of the page where the form is loaded, but the function is not available, any reference to it through the debug console says it is "not defined"
If I add the same code in a custom Joomla! module, it is available.
And I am still confused by where to place the validation to call the custom scripts inside the ChronoForms v6 system. I have seen posts that made vague references to the Field's Events tab, but can't find out where to call my custom functions even if I have to load them outside of CF.
In other forms I have had a variable X = function() { ... } and referenced the field value from 'this.value' inside the funciton. Then added onchange/onblur/etc. to the input element in the DOM. For the life of me I don't know where to go from here insde CF.
In just getting simple routines moved over into CF, I want o reformat the input of a field, replacing the user input with proper or upper case as needed as they leave the field or as the field input changes, etc.
To start, I have a simple script that changes text to proper-case. I place the function inside the Custom javascript Content, and I have tried Add inside domready as well.
The function shows up in the source code of the page where the form is loaded, but the function is not available, any reference to it through the debug console says it is "not defined"
If I add the same code in a custom Joomla! module, it is available.
And I am still confused by where to place the validation to call the custom scripts inside the ChronoForms v6 system. I have seen posts that made vague references to the Field's Events tab, but can't find out where to call my custom functions even if I have to load them outside of CF.
In other forms I have had a variable X = function() { ... } and referenced the field value from 'this.value' inside the funciton. Then added onchange/onblur/etc. to the input element in the DOM. For the life of me I don't know where to go from here insde CF.
In just getting simple routines moved over into CF, I want o reformat the input of a field, replacing the user input with proper or upper case as needed as they leave the field or as the field input changes, etc.
function myFunction() { blah blah; }
Then for the field, one of the available field events is "onChange", and you put the NAME of your function in there without the brackets.
Then for the field, one of the available field events is "onChange", and you put the NAME of your function in there without the brackets.
in my JavaScript I have:
also, in the console, if I try to invoke the function for testing it says its not defined...even though if I show source the function exists in the page.
function regNameCase(str) {and in my onChange field event I tried regNameCase({data:fullname})
separators = ['-',' '];
caseregx = new RegExp('(^|[' + separators.join('') + '])(\\w)', 'g');
if (str.length) {
return ustr.toLowerCase().replace(caseregx, function(x) { return x.toUpperCase(); });
}
}
also, in the console, if I try to invoke the function for testing it says its not defined...even though if I show source the function exists in the page.
Definitely don't put the dom ready bit for that code. And does it say the FUNCTION is not defined, or that 'fullname' is not defined? Because you can't use shortcodes in javascript.
The value of the field will be passed by the onchange event, don't put the brackets or the {data:fullname} thing in.
The value of the field will be passed by the onchange event, don't put the brackets or the {data:fullname} thing in.
I’ll check again. But with the javascript it says function regNameCase is not defined (From the browser console when I manually try to invoke the function)
Hello
Do you have an response ? A solution ?
Thanks a lot.
Jean-Marie
Do you have an response ? A solution ?
Thanks a lot.
Jean-Marie
If they're trying to invoke the function directly and it's not defined then their code is either wrong or not being loaded.
This topic is locked and no more replies can be posted.