Highlighted

Showing error on validation form

New Here ,
Feb 18, 2020

Copy link to clipboard

Copied

Hi everybody! I’m struggling with an issue regarding a validation form and showing an error. If the user wants to Add a New User, and if he clicks Submit button without entering a value(number) into the Age field, an error message must be shown. After I click the Submit button, an error from ColdFusion administrator appears…
While editing/adding the user information, the Age validation should be in place. If no value is provided, an error should occur. Empty value should not be allowed.
 
// Some validation form
public array function validateForm (
required string last_name,
required string first_name,
required numeric age
)
output="false"
hint="Some validation to from not empty"
{
var Error = arrayNew(1);
if(arguments.last_name EQ '')
{
arrayAppend(Error,'Please provide a valid Last name');
}
if(arguments.first_name EQ '')
{
arrayAppend(Error,'Please provide a valid first name');
}
if(arguments.age EQ '' OR NOT IsNumeric(arguments.age) )
{
arrayAppend(Error,'The age is empty or not number');
}
return Error;
}
TOPICS
Advanced techniques

Views

248

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Showing error on validation form

New Here ,
Feb 18, 2020

Copy link to clipboard

Copied

Hi everybody! I’m struggling with an issue regarding a validation form and showing an error. If the user wants to Add a New User, and if he clicks Submit button without entering a value(number) into the Age field, an error message must be shown. After I click the Submit button, an error from ColdFusion administrator appears…
While editing/adding the user information, the Age validation should be in place. If no value is provided, an error should occur. Empty value should not be allowed.
 
// Some validation form
public array function validateForm (
required string last_name,
required string first_name,
required numeric age
)
output="false"
hint="Some validation to from not empty"
{
var Error = arrayNew(1);
if(arguments.last_name EQ '')
{
arrayAppend(Error,'Please provide a valid Last name');
}
if(arguments.first_name EQ '')
{
arrayAppend(Error,'Please provide a valid first name');
}
if(arguments.age EQ '' OR NOT IsNumeric(arguments.age) )
{
arrayAppend(Error,'The age is empty or not number');
}
return Error;
}
TOPICS
Advanced techniques

Views

249

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 18, 2020 0

Have something to add?

Join the conversation