Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to restrict to specific value in a field using javascript

anand_gpApr 13 2018 — edited Apr 13 2018

Hi,

I wanted to know how to restrict value of a field using javascript.  For example, if I want LENGTH field to have only value as either 10, 20 or 30 I use below javascript code -

Element attribute as -

onchange="javascript:Check_Value(this);"

Javascript code as -

function Check_Value(pThis) {

   var myvalue = $(pThis).val();

   if (myvalue == "10" || myvalue == "20" || myvalue == "30" ) {

   }

   else

   {

     alert("Invalid value");

     return false;

   }

}

However, it will only alert me if value is not as expected, but still continues to next field.  I wanted to know, how to restrict my control to same field unless the proper value is given?  Please help.

Thanks,

-Anand

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2018
Added on Apr 13 2018
20 comments
937 views