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-7: Create a SSRS report group by Case, retrieve all work orders and make work orders as sub group, retrieve all bookable resource bookings based on work order. If booking is completed then show the row color as green.

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 2: Generate a report on individual student, if I click on the payment details report in student record. It need to show all the transactions done in current year along with sum. (it should show for each student separately)