Java Script Task-6: On change of phone number, need to validate, it should contain only numbers and + symbol if any other characters are there then showing the error “Invalid value, please enter only numbers or +”

 User Story: If you enter the phone number in phone number field then need to validate that only accept numbers and + symbols if you entered other than these show error as Invalid value, please enter only numbers or + symbol.

1)  1)      Create one Phone number field in respective entity

2)      Write Java Script code:

·         Retrieve the phone number

·         Give the null check as if phone number is not equal to null and phone number is not equal to undefined then provide the phone number format.

·         If given phone number as matches to given phone number format the clear the notification

·         Otherwise provide the error notification.

3)      Create one web resource and add created java script code here.

4)      Open Entity form Properties and add this Web Resource

·         Add On change event of Phone number field

 

function phoneNumber(executionContext)

{

    var formContext = executionContext.getFormContext();

    var phone = formContext.getAttribute("effi_phonenumber").getValue();

    if (phone != null && phone != undefined)

    {

        var format = /^\+?[0-9]{10}$/;

        if (phone.match(format))

        {

            formContext.getControl("effi_phonenumber").clearNotification();

 

        }

        else

        {

            formContext.getControl("effi_phonenumber").setNotification("Invlaid Value, please enter only 10 numbers starts with +");

        }

    }

}

Add above code in web Resource

and give field on change event



Output:

 

Comments

Popular posts from this blog

SSRS User Story-8: Create a SSRS report on the Opportunity entity, show the source lead and campaign details.

SSRS User Story-6: Prepare a SSRS report on the birthday, In First part, group by with date of birth. In second report, prepare the wishes card with individual students.

SSRS User Story 3: In order entity create a report look like mentioned below, it should show the address of selected customer and products dynamically.