facebook

Clearing text on click

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    Cary_R
    Member

    I was wondering how to go about clearing existing text in an input box when the user clicks on the input box. I’ve only really been able to execute code so far with buttons.

    #328684

    Max87
    Member

    Hi,
    if you want to have temporary text in text field(like search, enter name) which disappears when user clicks on text box, try to use Text placeholder in Design center.
    If you want to clear text previously entered by user, I think you have to write a function and call it by button.

    #328716

    Kale
    Member

    Hi,

    this should work:

    $(function() {
    $(‘input[type=text]’).focus(function() {
    $(this).val(”);
    });
    });

    Kale

    #329578

    byrdland
    Member

    It worked great! How do you learn this stuff? I could use some help. Thanks

    #329579

    adikate
    Member

    does it work if i get a result on a text, because when i use text in design centre to get my result, there are no on click actions that are to performed(javascript, Gotoscreen, etc).

    #329625

    byrdland
    Member

    Hi, adikate, you are correct, there is no click event for a text box in mb1 but the above function that kale mentioned works in it’s place. In the function, ‘input[type=text]’ is made up of the HTML tag of input and Attribute of type= text and will work for all widgets with a tag of input and attribute of type=text that can recieve focus. If you want it to work on a particular widget, just replace ‘input[type=text]’ with the id of the widget. This only works for widgets that can recieve focus, not all can, and it is usually only used on text or input widgets. So for instance, if you have a project called Untitled2 and you put a text area widget in it, it will have an id of m1-Untitled2-textArea1, put it in place of input[type=text]. Put the function in the Untitled2_custom.js file at the bottom. The function will only fire if the text box is clicked or tabbed to, it wont fire if a result is placed in it.

    so, replace this

    $(function() {
    $(‘input[type=text]’).focus(function() {
    $(this).val(”);
    });
    });

    with this

    $(function() {
    $(‘#m1-Untitled2-textArea1’).focus(function() {
    $(this).val(”);
    });
    });​

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Clearing text on click

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