Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Validation script that looks for a specific number

Avatar

Former Community Member
We have a form that in one of it's field you can enter phone number.

We want a script that checks that the first digit entered is 0.If another digit is being entered a pop up message will appear that the digit entered is not correct.

What is the script in order to achieve this ?
3 Replies

Avatar

Level 5
Drop this FormCalc code in 'exit' event of the field.

var FirstDig

FirstDig = Left($.rawValue, 1)

if (FirstDig <> 0) then

xfa.host.messageBox("Please check the number. Phone number has to start with '0'.")

endif



Good luck,

SekharN.

Avatar

Level 2

Fantastic, I was trying to force users to only insert urls from my domain and this worked a treat!

Cheers mate...

var

FirstDig

FirstDig

= Left($.rawValue, 20)

if

(FirstDig <> "http://mydomain.co.uk") then

xfa.host.messageBox("Please use http://mydomain.co.uk, files are more secure there!")

$.rawValue

= null

endif