1 2 Previous Next 15 Replies Latest reply on Nov 14, 2016 10:57 AM by philmodjunk

# Numeric Only Script

i have a field call Starting year  he accept only 4 degitels and is numeric only

how i can do this script

• ###### 1. Re: Numeric Only Script

The Year() function?

Year( Get(CurrentDate) ) will return 2016.

• ###### 2. Re: Numeric Only Script

i went to never enter day and month only year

• ###### 3. Re: Numeric Only Script

Are you trying to validate a user entering in a year value? or are you trying to script the entry of a year into a field?

The former, you can use a simple calculation to validate the input:

Length(GetAsNumber(self)) = 4 and self > 1900

That will validate that the value is numeric, four characters, and greater than 1900.

If you want to adjust so it's at least the current year and 4 characters:

Length(GetAsNumber(self)) = 4 and self > Year(Get(CurrentDate))

If you just want to make sure it's equal to the current year:

self = Year(Get(CurrentDate))

To script, use the Year() function to get a year out of some date you specify (or just pass the four digit year), using the Set Field script step.

• ###### 4. Re: Numeric Only Script

i have a button inside this button i have a script to validate the fildes

1-the Filde accept only nomber

2-only 4 digits

And Thank you for helping

• ###### 5. Re: Numeric Only Script

The plot thickens.

Not. (At least not for me.)

• ###### 6. Re: Numeric Only Script

So you are validating what a user inputs, scripts have nothing to do with this.

You can uncheck the other validation and check "validate by calculation".

Then use the calculation I pointed out before:

If you want to adjust so it's at least the current year and 4 characters:

Length(GetAsNumber(self)) = 4 and self > Year(Get(CurrentDate))

Then you can specify a custom message for if that fails that says "Enter a 4-digit year that is at least the current year".

• ###### 7. Re: Numeric Only Script

In field options on the validation tab, you can also specify a strict data type of "numeric only" and limit the number of characters to 4.

Then you validation calculation need only be:

self >= year ( Get ( Currentdate ) )

(It looks like Mike left out an = in his example...)

• ###### 8. Re: Numeric Only Script

how i can deactivate characters

example :

he pressing on "a" ------> "" (Empty)

he pressing on "1" ------> "1"

• ###### 9. Re: Numeric Only Script

If you want results while a user is typing, then you need to use script triggers.

If you just want to strip it after the user has entered, you can use:

Filter( self ; “0123456789” )

As part of an auto-enter calculation.

(thanks for picking up the >= phil )

• ###### 10. Re: Numeric Only Script

u canmake this in image

• ###### 11. Re: Numeric Only Script

I want script triggers

• ###### 12. Re: Numeric Only Script

Here is the documentation for Script Triggers:

Here is a video about how to use script triggers:

Documentation for the filter function:

Documentation for the self function:

Video explaining auto-enter fields:

• ###### 13. Re: Numeric Only Script

i want to use OnbjectKeyStroke and Filter ( self; "0123456789")

How ??

• ###### 14. Re: Numeric Only Script

Both the video and documentation I link to provide details on using triggers.

1 2 Previous Next