Page 1 of 1

Checking for empty input on mobiletextinput

Posted: Thu Nov 22, 2012 5:55 pm
by Stavros

What is the JS to put on the click event of a button in order not to go forward if the user ommits to enter his/her name, number into two mobiletextinput of type text and number? Maybe something like

var name = Tiggr('mobiletextinput1').val();
var number = Tiggr('mobiletextinput2').val();

if (name != ' ' || number != ' '){
alert ('Please enter you name number');
return;
}

and then put a Navigate to page action

It does not work for me...


Checking for empty input on mobiletextinput

Posted: Fri Nov 23, 2012 12:15 am
by maxkatz

It looks right.. but you need to debug the JavaScript. Check first what you get in 'name' and 'number'. You can use console.log(name); -- for example.


Checking for empty input on mobiletextinput

Posted: Mon Mar 25, 2013 7:39 pm
by Martin Davis

Shouldn't the logic be:

if (name == '' || number == '') {
alert('error message of your choice');
}

???

And, then my question, is how do you add a "Navigate to page" action inside the JS?


Checking for empty input on mobiletextinput

Posted: Mon Mar 25, 2013 7:58 pm
by Kateryna Grynko

Hi Martin,

This is the correct JavaScript code.

You can navigate to page using the following JavaScript code:
codenavigateTo('pageName');/code
where 'pageName' is a name of Tiggzi page.