Kevin
Posts: 0
Joined: Sun Oct 07, 2012 7:58 pm

Required Field . . . How to?

I've tried putting this code but its not working please help:

precode
function checkInputs(){var inputpass = Tiggr('password').val();
var inputuser = Tiggr('username').val();
var inputemail = Tiggr('email').val();
var button = Tiggr('registerbutton');

if (inputpass == '' && inputuser == '' &&inputemail == '') {
button.addClass('ui-disabled');
}

else {
button.removeClass('ui-disabled');
}}

/code/pre

The button is completely disabled even if i fill all fields.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Required Field . . . How to?

Is it disabled when the page loads? You want to test which of the if-statements is actually being invoked.

Kevin
Posts: 0
Joined: Sun Oct 07, 2012 7:58 pm

Required Field . . . How to?

Yes the button is disabled on page load.
I've put this code on page load custom JavaScript tab
precode
var button = Tiggr('register');
button.addClass('ui-disabled');
/code/pre

Then this code on value change of the 3 fields:
precode
function checkInputs(){var inputpass = Tiggr('password').val();
var inputuser = Tiggr('username').val();
var inputemail = Tiggr('email').val();
var button = Tiggr('registerbutton');

if (inputpass == '' && inputuser == '' &&inputemail == '') {
button.addClass('ui-disabled');
}

else {
button.removeClass('ui-disabled');
}}
checkInputs()
/code/pre

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Required Field . . . How to?

The code seems correct... but in one place you have:

var button = Tiggr('register');

and then you have:

var button = Tiggr('registerbutton');

Kevin
Posts: 0
Joined: Sun Oct 07, 2012 7:58 pm

Required Field . . . How to?

Thanks I've corrected the code.
But this time whenever i just fill one of the fields the button is enabled.

I would like the button enabled only if all the fields are filled.

Any suggestions?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Required Field . . . How to?

Hello!

Here

if (inputpass == '' && inputuser == '' &&inputemail == '') {
button.addClass('ui-disabled');
}

replace && with ||

Kevin
Posts: 0
Joined: Sun Oct 07, 2012 7:58 pm

Required Field . . . How to?

Thank you very much Marina.
It worked perfectly.

Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Required Field . . . How to?

Hi!

I am also having trouble with same thing as Kevin had. So I have a screen called regScreen then I have 4 input fields namely, regEmail, regPass, regConfirmPass and regUsername. My button is called btnReg.

On the load event of the regScreen I have the following code:

var button = Tiggr('btnReg');
button.addClass('ui-disabled');

this works and disables the button on load.

Q1)
So now under the value changed event of the fields I added custom javascript I placed the following code there.

var username = Tiggr('regUsername').val();
var email = Tiggr('regEmail').val();
var pass = Tiggr('regPass').val();
var cpass = Tiggr('regConfirmPass').val();
var button = Tiggr('btnReg');

if (username '' email != '' || pass != '') {
button.addClass('ui-disabled');
}
else {
button.removeClass('ui-disabled');
}

But this is not working, the button just stays disabled. I feel like I am declaring the variables wrong maybe?

Q2)
Also I'd like to create this as a function to globally be accessible by this page. Where would I insert the javascript to do this?

Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Required Field . . . How to?

Another thing, what is the "Tiggr" reference for when used to declare variables?

Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Required Field . . . How to?

Wait I think I have messed this up. Let me first check again.

OK My logical operators were a mess. It works now! But I'd still like to know about Q2 and the question in the previous comment. Thanks!

Return to “Issues”