facebook

Text to Upper Case

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #337573 Reply

    Robert Gardner
    Participant

    Is there a way to change text in a text field to uppercase when it’s entered?

    #337576 Reply

    Brandon
    Member

    Try something like this:

    var txt=$(‘m1-formanme-textField1’).val(); // get String from textbox
    var txt1=txt.toUpperCase(); // txt1 is txt converted to upper
    $(‘m1-formanme-textField1’).val(txt1); //place text back in textfield

    #337580 Reply

    Robert Gardner
    Participant

    I’ve attached the screen and the properties for the field I want to change to upper case… This is a really simple (and my first) to see if I want to purchase this Mobione tool. The box to the right is where text (up to 4 characters) will be placed. I want to convert those characters to upper case. When the user taps send it! the an email is generated using the email function within Mobi (not a form). It’s being run on the Ios platform. Could you be more specific on the exact code and how to implement?

    Thank you,

    Attachments:
    You must be logged in to view attached files.
    #337584 Reply

    Brandon
    Member

    Oops, my fault I forgot the #
    Put this in the on change action of the text field,, which it looks like you did, once the textbox loses focus it will change them to upper case

    I did test it also so I know it works…

    var txt=$(‘#m1-formname-textField1’).val(); // get String from textbox
    var txt1=txt.toUpperCase(); // txt1 is txt converted to upper
    $(‘#m1-formname-textField1’).val(txt1); //place text back in textfield

    #337586 Reply

    Robert Gardner
    Participant

    I must be doing something wrong (not surprising) because it doesn’t work. I copied and pasted your exact code into […] area for the javascript and nothing happens. Do I need to change any of the variable names or something?

    I do thank you for your assistance in getting me jump started with this…

    #340048 Reply

    Robert Gardner
    Participant

    I would like to ask again if there is something else I should be doing to get this script to convert the text entered to upper case. I’ve copied pasted verbatim as provided and it’s not working… Apologies. I’m a newbie at this.. Thanks for your patience.

    #340050 Reply

    Stu Wade
    Member

    I think your problem lies with the somewhat arcane nature of widget naming supported by MobiOne.
    These consist of three parts…
    1) m1
    This is a prefix which can be changed, but basically simply identifies the app as a product of MobiOne
    Hyphen
    2) the page name, essentially the name of the .mobi file, thus xxx.mobi you would use xxx, but hyphens are shifted to underscores and errors have been reported when the leading character is numeric.
    Hyphen
    3) the widget name which is set in the Id field of the widget itself

    Thus widget textfield1 in Fred.mobi would be identified by m1-Fred-textfield1 the additional # at the beginning is, I believe, required by the underlying jQuery structure.

    So, yes, you do need to change the identifiers to match your development.

    Hope this helps

    #340056 Reply

    Robert Gardner
    Participant

    Great thanks Stu…I appreciate the detailed naming convention explanation… I’ll check that out. I’m sure that’s the ticket.

    #340057 Reply

    Robert Gardner
    Participant

    Stu – Perfect that works.. Any thoughts on the local time / utc time question i posted?

    Thank you,
    Bob

    #340060 Reply

    Stu Wade
    Member

    You are most welcome, that is what this forum is for.
    As regards local and universal time, I suggest you Google ‘JavaScript date object’ I suspect that getHours and getUTCHours are what you are looking for.

    #340061 Reply

    Stu Wade
    Member

    Sorry, I can’t give the exact details at this time – I’m on holiday sailing in Spain – so somewhat separated from my lappie. (These postings are from my iPad) but your question is basically an easy one and if no one else has posted the code for you I will post it once I return home on Thursday.
    Basically, you need to insert some code into the stubbed function in the xxx_custom.js file that runs on load. This code will resemble and without my lappie the syntax is VERY questionable.

    Var today = new date();
    Var mins = getMins(today);
    Var local = getHours(today);
    Var univ= getUTCHours(today);
    Var localtime = local + ‘:’ + mins;
    Var UTCtime = univ + ‘:’ + mins;
    $(‘#m1-xxx-textfield1’).val(localtime);
    $(‘#m1-xxx-textfield2’).val(UTCtime);

    The Var(s) should all be lowercase and I suspect that date should be Date.
    Sorry I can’t be more precise from here.

    #340125 Reply

    Stu Wade
    Member

    As promised, the .zip file contains a simple .mobi for displaying the time in local and UTC variants and the associated -www folder – simply unzip the provided file and open the TimeTest.mobi in MobiOne.

    The code you need is contained in the file TimeTest_custom.js file in the TimeTest-www folder.
    This file is initially generated by MobiOne with the essential stubs required for the app to function. You add your own functionality by editting the file including your own functions and, where required, populating the stubbed functions.
    I have included a fair amount of comment to hopefully explain what I have been up to.

    Good luck …

    Published as WebApp here http://goo.gl/OoNcQ

    Attachments:
    You must be logged in to view attached files.
    #340127 Reply

    Rathinavel
    Member

    Hi Stu Wade,

    I used

    getNow(); // this will be invoked on application load
       $('#m1-TimeTest-textField1').val(lTime); // putting the pseudo output parameters into the required fields
       $('#m1-TimeTest-textField2').val(uTime);
      setTimeout(getNow, 1000);
       return true; 

    to update the clock every 1 second.

    but it doesn’t happen.

    anywhere I’m going wrong…!?

    Please let me know where I’m going wrong.

    @Stu Wade wrote:

    As promised, the .zip file contains a simple .mobi for displaying the time in local and UTC variants and the associated -www folder – simply unzip the provided file and open the TimeTest.mobi in MobiOne.

    The code you need is contained in the file TimeTest_custom.js file in the TimeTest-www folder.
    This file is initially generated by MobiOne with the essential stubs required for the app to function. You add your own functionality by editting the file including your own functions and, where required, populating the stubbed functions.
    I have included a fair amount of comment to hopefully explain what I have been up to.

    Good luck …

    Published as WebApp here http://goo.gl/OoNcQ

    #340129 Reply

    Stu Wade
    Member

    @ Rathinavel

    You are pushing the limits of my JavaScript experience here, but there are several things awry with your code above.
    1) setTimeout I believe only executes once so it will only recalculate ‘now’ after 1 second and not at one second intervals.
    2) my function getNow simply acquires the current time, the two statements that follow the function call place it in a visible location.

    If, however, you replace your setTimeout line with the following:

    setInterval(showCurrentTime, 5000);

    I believe you will achieve the desired effect.

    Added in edit:
    Yes that does it see the attachment …

    find as a WebApp here http://goo.gl/0CAUb

    Attachments:
    You must be logged in to view attached files.
    #340131 Reply

    Rathinavel
    Member

    Hi Stu,

    Since I’m a newbie in Programming I will ask questions like this 😀

    And sorry for pushing you to the limits of JavaScript. 😀

    And Thanks for the code snippet, I will try with it and tell you the feedback how it worked 🙂

Viewing 15 posts - 1 through 15 (of 17 total)
Reply To: Text to Upper Case

You must be logged in to post in the forum log in