How can I make text on a new record enter the data in to the database with a specific format? ie ALL CAPS or Title Case
I have worked out how to format displayed text with styles but not how to format it on data entry.
Thanks
Welcome to the nuBuilder forums!
Please register and login to view forums and other content only available to registered users.
Please register and login to view forums and other content only available to registered users.
Text Formatting
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Text Formatting
barrydocs,
you could use Javascript to validate/format fields.
Two ways:
Max
you could use Javascript to validate/format fields.
Two ways:
- for single field with simple format you can use On Blur event on the object:
- for many fields and/or more complex formats, you can build a JavaScript function in Custom Code > Javascript and use both OnBlur event and nuBeforeSave() function:
Code: Select all
/* * Check data validity and format text field */ function nuBeforeSave() { return ( validateField('my_first') && myCustomFormat('my_second') //... ) ? true : false); } function validateField(fieldName) { // Check data validity } function myCustomField(fieldName) { // Apply custom format }
Max
-
- Posts: 18
- Joined: Wed Dec 18, 2013 4:44 pm
Re: Text Formatting
Max,
Thanks for the reply. As you might have guessed from the very basic nature of the questions I am asking, I am pretty new to this. I am still struggling with mysql and php, I think JavaScript is a way out of my skill set at present
Anyway, please would you be so kind as to give a brief breakdown of the 2 script examples you have suggested so that I might have an idea where to start?
Thanks
Adrian
Thanks for the reply. As you might have guessed from the very basic nature of the questions I am asking, I am pretty new to this. I am still struggling with mysql and php, I think JavaScript is a way out of my skill set at present
Anyway, please would you be so kind as to give a brief breakdown of the 2 script examples you have suggested so that I might have an idea where to start?
Thanks
Adrian
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Text Formatting
Adrian, to format a field on data entry you have to:
Max
- login as globeadmin;
- open the form in Edit screen;
- double-click on the label of the field you want to format: this open a new window on the object (the same window can be opened in Setup > Objects > <your-object>);
- in All tab > On Blur field you have to enter the Javascript (or, better, jQuery) code to execute when the user leave the field; so, if you enter this jQuery code:
when the user leave the field the text he/her entered is being transformed in uppercase;
Code: Select all
$(this).val($(this).val().toUpperCase());
- depending on what format you have to apply, the JavaScript (or jQuery) code is different; this is for Title Case:
Code: Select all
$(this).val($(this).substring(0,1).toUpperCase()+$(this).substring(1));
Max
-
- Posts: 18
- Joined: Wed Dec 18, 2013 4:44 pm
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact: