facebook

How to check input value? – ANSWERED

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

    Albatros78
    Participant

    Hi,

    I used the login / password template from mb1

    When the form action link will work properly (issue in another post), I would like install a check function in JS to validate if the two input fields are not blank. If one of them is blank an alert message is displayed.

    I have this js funtion ready (from a normal web site), but where install it and how ?

    Need I to modify the html source file genereted from mb1 and add my JS reference on the top of html file and add my .js file as an external js file into the application ?

    Regards

    #311924 Reply

    Albatros78
    Participant

    Hello,

    Does anyone has an answer ?

    #311939 Reply

    wayne
    Moderator

    If your design is marked as a Form (see Properties Editor) then when you generate HTML code, a companion javascript file will be created with the naming convention <yourdesignname>_custom.js. You can safely add any javascript functions or modify current form functions in this file. This file includes a function named with the pattern preSubmit<formName>(theForm). You should add all validation or preprocessing to this function.

    Wayne
    Genuitec Mobile Team

    #311940 Reply

    Albatros78
    Participant

    Ok..
    Does this explanation works even if the form submit does not works today.

    I can uderstand in this case that I can put for example a ‘ok’ button in the form, and add a JS script which is inside the link button where is refererred into the designname_custom.js file

    Or does I need to write my js function just into the presubmit function with not anything more ! Does this function is automatically called by the form at loading and leaving ?

    Does it right ?

    #311943 Reply

    wayne
    Moderator

    The preSubmit<Form>() and postSubmit<Form>() generated functions in the <design>_custom.js file are named for the points in the form processing workflow that they are call. So if you need to preform form validation customize the preSubmit function. Below are examples of the 2 functions stubbed out and ready for customization.

    function preSubmitTest_form(form) {
      // add custom presubmission code here, e.g., form validation & error handling
      // return false to terminate form submission
      return true;
    }
    
    function postSubmitTest_form(success, data) {
      // add custom postubmission processing code here,
      // e.g., parse and process results & update UI controls with data as needed
      // return false to terminate form processing
      var result = true;
      if (success) {
        // process data
        result = true;
      } else {
        // submit failed
        // data = error msg
        result = false;
      }
      return result;
    }

    Wayne
    Genuitec Mobile Team

    #312471 Reply

    Albatros78
    Participant

    Hi Wayne,

    With mb1 Beta 2, I try to use the form action.

    My sample is:

    First page is home.mobi and second page is menu.mobi.

    In properties the first page is declared as:
    form= yes
    form method=post
    form URL = menu.mobi
    form result = web page

    I have just one button which is declared as form action= submit.

    When I run that and I click on my button, nothing appears and the second page is not displayed !

    something is wrong from my side to run the form method correctly ?

    #327628 Reply

    Halusafed
    Member

    Thanks Wayne,

    but I am new to java and need a little help with the “custom presubmission code”
    -What is it and what might be an example?

    #327925 Reply

    Hi Halusafed,

    We are working on a form guide. Probably will be available late next week.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: How to check input value? – ANSWERED

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