Page 1 of 1

Mandatory Fields

Posted: Thu Mar 27, 2014 6:21 pm
by Dan6766536

Hi. I've used appery.io to build a simple app to collect information from my customers. I want to make it mandatory for all the app input fields to be populated before a customer can submit data. How do I acheive that? Dan


Mandatory Fields

Posted: Thu Mar 27, 2014 7:40 pm
by Nikita

Hello,

You should add a handler to the "submit" button, that will verify all the required fields and prevent its sending, if the data isn't entered.


Mandatory Fields

Posted: Thu May 01, 2014 5:04 pm
by Janise Dismuke

What code did you use ?


Mandatory Fields

Posted: Fri May 02, 2014 2:10 am
by Yurii Orishchuk

Hi Janise.

It's up to you what code to use.

But you can use following one(add this to the submit button click):

'''

//name_field - is a name of the input component that's need to be validated on empty value.
var name = Appery("name_field").val();

//Validation condition
if(name == ""){
alert("Please fill the name field");

Code: Select all

 //Get out here if validation not passed 
 return; 

};

//Run update/create service if validation is passed.
serviceName.execute({});

'''

Regards.


Mandatory Fields

Posted: Sat May 17, 2014 3:55 am
by Dan Hoeck

This is very helpful! The one thing I could use, to add to this, is how do you add validation of a radio button?

I am using the following script which is not working:

var radioButton = Appery("mobileradiobutton_1").checked;

if(radioButton == "false"){
alert("Please select an option from the list");

return;
};


Mandatory Fields

Posted: Mon May 19, 2014 5:37 am
by Evgene Karachevtsev

Hello Dan,

Let's try using this code:

codevar radioButton =$('input[name=mobileradiogroup_5]:checked').val();

if(radioButton){
alert("Please select an option from the list");

return;
}; /code
where "mobileradiogroup_5" is the name of your radiogroup component


Mandatory Fields

Posted: Mon May 19, 2014 4:44 pm
by Dan Hoeck

Thank you, this worked! I just had to add in -- if(radioButton == null)
otherwise the following code worked great:

var radioButton =$('input[name=mobileradiogroup_5]:checked').val();

if(radioButton -- null){
alert("Please select an option from the list");

return;
};