JavaScript Function to validate an item's value

Can somebody please tell me how to write a Javascript Function that, upon losing focus on a text item, checks if the value just entered is a 6 digit number?
Please show me the function and what the onblur command in the item would be. The name of the item is P21_PERMIT_NUMBER.
BTW, this can't be done in a Validation, since it must be done onblur, which does not submit the page.
Also, if there already is an onKeyPress for this item, what do I do? Do I just put a comma after the onKeyPress command and write the onblur command after it?
Thanks.

Prohan,
Take a look at the following link to see how to do validation within a javascript function: Re: Implementing in-field validation the simple way.
Thank you,
Tony Miller
Webster, TX

Similar Messages

  • Javascript function did't get item value

    Hallo,
    I setup the HTML Form Element Attributes from an select list:
    style="width:265px" onclick="javascript:load('&P3_LOAD.')"
    The problem is that the javascript function "load()" did't get the value of the item P3_LOAD.
    Maybe I forgot some '' ?
    Thank you in advance.

    Hello Michael,
    Try
    style="width:265px" onclick="javascript:load($v('P3_LOAD'))"
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • Any existing function to validate an item when other item has been changed?

    Any existing function to validate an item when another item has been changed? Because these 2 fields are related. When one filed is changed, the other one should be blank and let the user to input again. I am using oracle custom.pll library.
    Any ideas?
    Amy

    Hi Vikram,
    Thanks for posting your issue,
    You can switch of alerts and set E-Mail Notification to Yes under your Workflow Tasks list > Settings > Advanced Settings. By doing so user specified in AssignedTo will receive e-mail notification when task is created and if task ownership is not changed
    during your workflow this will be the only mail sent by system.
    Since you are already using SharePoint designer you also have option to include Send an Email action in your workflow (after task is created). This option is better if you want to send some specific info to user.
    Also, browse the below mentioned URLs to create workflow step by step
    http://sharepointsolutions.com/sharepoint-help/blog/2010/03/create-a-detailed-custom-task-notification-with-a-sharepoint-designer-workflow/
    http://sharepoint-community.net/forum/topics/configure-email-notification-for-discussion-board-activity
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • WAD: Add variable to a called javascript function on button group item

    Hi All,
    I need your expertise regarding the following problem:
    To increase performance, I've decided to hide all analysis tables. To set these tables to visible, there is a button to switch the state for each table.
    Because this function is needed for each table, the function has two parameters for the analysis item name and the new state.
    Unfortunately, I get an useless error message after calling the function.
    The function in script item looks like
    function switchTable(itemName, newState)
    The function is started by a button of a button group item as javascript and the following script function
    switchTable('ANALYSIS_ITEM_1', 'VISIBLE')
    If I enter a without parameters, that will call the function with these parameters, it works.
    But if i try this directly from the script function in the button parameters, the function will be called correctly, but an error occurs and the analysis item wasn't displayed or the sendCommand wasn't processed completely.
    I hope there is a way to call javascripts by a button with variables, otherwise I would have to create many functions with only an other item_ref.
    Many thanks in advance and points of course for any help.
    Regards,
    Tobias

    One short note:
    It's possible to trigger the same function by an html input form button with onlick switchTable('ANALYSIS_ITEM_1', 'VISIBLE')
    and this works.
    Has anyone an idea what's the problem with a normal button item of the button group item?
    Another possibility is a menu item. The functions were called, but errors were shown.

  • How to put a jsp variable into a javascript function?

    Please read the following coding. I want to pass the variable ans from jsp to the function check_answer() of javascript. ans is a string got from database. But I cannot put the variable ans into the Javascript function. Can anyone help?
    <script language="Javascript">
    function check_answer() {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer()'>");
    %>

    The following should be able to pass ans.
    <script language="Javascript">
    function check_answer(ans) {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer('<%= ans%>')'>");
    %>jag

  • How to passed an xsl parameter to a javascript function inside an xsl styel

    Hi:
    I am having problem passing an xsl param variable as a parameter to a javascript function inside an
    xsl styelsheet.
    Here is my xsl stylesheet.
    >
    <xsl:param name="numberOfRecordsFromDatabase" select="search-result/rec-num" />
    <xsl:template name="Body">
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
    onLoad="cloneHeader();window.parent.shrinkIFrame(<xsl:value-of select='$numberOfRecordsFromDatabase'/>);"
    onresize="cloneHeaderResize();window.parent.shrinkIFrame(<xsl:value-of select='$numberOfRecordsFromDatabase'/>);">
    </body>
    </xsl:template>
    I am trying to pass a variable called numberOfRecordsFromDatabase to
    a javascript function called window.parent.shrinkIFrame(<xsl:value-of select='$numberOfRecordsFromDatabase'/>).
    Is this possible?
    If not, is there a way to do this.
    Any hint would be greatly appreciated.
    Yours,
    Frustrated.

    I would do it like this:
    Load the "search-result/rec-num" value into a field within an invisible div tag:
    <div id="miscproperties" style="visibility:hidden">
       <input id="numberOfRecs" type="text">
          <xsl:attribute name="value">
             <xsl:value-of select="search-result/rec-num"/>
          </xsl:attribute>
       </input>
    </div>Then, your js function can retrieve the value via
    var x = document.getElementById("numberOfRecs").valueR. Grimes

  • How to pass Application Item value in Javascript function.

    Hi,
    I have the following javascript in the HTML Form Element Attributes properties
    I am on Page1 and passing P1_DEPT_NO page item value. This is working perferctly fine and I am able to get the exact value of the page item
    onchange="javascript:function1($x('P1_DEPT_NO').value);"I am on Page1 and passing Application Item G_DEPT_NO value.
    The problem here is, I am not getting the Application item value inside the javascript function.
    I tried using alert(); and it's giving me value as undefined
    onchange="javascript:function1($x('G_DEPT_NO').value);"Just want to know, how to pass the Application Item value in Javascript.
    Thanks,
    Deepak

    Deepak,
    I am not an expert at Javascript, but the suggestin I made was because javascript is a case-sensitive language.. and therefore onChange is not the same as onchange.
    Not quite sure if that is causing the problem.
    Application items are not associated with a page and therefore have no user interface properties.
    Therefore, as mentioned in another post, the rendering would not work for application items.
    If it is for a single item, used only in this page, you could create a hidden page item and use it fo your purpose
    If you still want to look at application items and AJAX, This page contains examples of using AJAX to solve problems like the one you mentioned.
    http://www.oracle.com/technology/obe/hol08/apexweb20/ajax_otn.htm#t1b
    Thanks,
    Rajesh.

  • JavaScript function which fetches return_value from List of Values

    Hi,
    I have created List of Values named "NICKS". I want to write JavaScript function "get_workers_fullname(nick)" which returns display_value from List of Values. The parameter of function is return_value of List "NICKS".
    I am new with this and don't know how to handle this case.
    Please help me.

    Hi,
    The LOV, I mean is the item in Application's Shared Components. I don't mean the visible SelectList on the page.
    This is what I found in ApEx's help: "A List of Values can be referenced by page items as well as report fields. It controls the values displayed and limits the user's selection. Lists of Values can be static (based on values you enter) or dynamic (based on a SQL query)."
    I'd like to access values in such LOV from JavaScript. I am not sure it is possible.
    Cheers,
    Tom.

  • Set multiple items with javascript function in chart link

    Hi Folks
    I am able to use the javascript $s function to set the value of one item from a chart link. I need to pass values to multiple items.
    Is there a way to use javascript function to pass values for multiple items on a page from a chart link
    Appreciate your responses
    Thanks
    Gopal

    Hi Arnau,
    You need to surround your JavaScript code like this (without the spaces before and after script):
    < script language="Javascript">
      window.open("<%=ABAP_VARIABLE%>").focus();
    </script >
    Regards,
    Patrick.

  • Page items are cleared when calling javascript function for a buton.

    Hello,
    Can anyone please help me out with this issue.
    I have a reports region with some editable items and in which I have a button enter errors which opens up an popup window, but for this button i also have save process which updates the report and also calls the javascript function popup window. The reason I am saving the report is because the values entered by user needs to be updated in the table or otherwise the page will be reloaded clearing all the values entered by the user when i click the button enter errors. One more thing is that I also have two hidden items (P1_LOAN and P1_HERITAGE) in the reports region.
    Below is the javascript function which i am calling for the button and also setting the items P2_LOAN_NUMBER,P2_HERITAGE with the values &P1_LOAN.,&P1_HERITAGE.
    function ErrorPopup()
    popUp2('f?p=&APP_ID.:2:&SESSION.::&DEBUG.::P2_LOAN_NUMBER,P2_HERITAGE:&P1_LOAN.,&P1_HERITAGE.','_blank','scrollbars=0,left=200,menubar=0,resizable=0,width=400,height=500,toolbar=0,location=0,directories=0');
    doSubmit('ENTER_ERRORS');
    }And below is my pl/sql update process
    BEGIN
    FOR i IN 1 .. apex_application.g_f01.COUNT
    LOOP
                 IF WWV_FLOW_ITEM.MD5(                                                      
                                           APEX_APPLICATION.G_f10 (i) ,
                                           APEX_APPLICATION.G_f11 (i) ,APEX_APPLICATION.G_f12 (i) ,APEX_APPLICATION.G_f13 (i)) <> APEX_APPLICATION.G_F45 (i) THEN
    -- Update tbl
              UPDATE sampl_tbl
              SET  col1     =      APEX_APPLICATION.G_f10 (i) ,
                         col2     =      APEX_APPLICATION.G_f11 (i) ,
                         col3     =      APEX_APPLICATION.G_f12 (i) ,
                         col4     =      APEX_APPLICATION.G_f13 (i)
                   WHERE pkcol    =      APEX_APPLICATION.G_f04 (i)         
         END IF;
    END LOOP;
    COMMIT;
    END;The only problem I have is, when I open up the popup window the hidden item values P1_LOAN and P1_HERITAGE are lost. Is their a way to set these item values within the session.
    thanks,
    Orton
    Edited by: orton607 on Jul 14, 2010 10:38 AM

    It HELPS when you solve an issue and POST that YOU SOLVED it, to SHARE the solution so others can learn from you found..
    Thank you,
    Tony Miller
    Webster, TX

  • Select list display value in javascript function

    Hi All,
    I have a select list in a tabular form having a display value & return value.
    I am using $x(var_name).value or $v(var_name) for retreving return value of the select list in a javascript function.
    Can anyone let me know how can I get the display value of the select list in a javascript function? Im using Apex 3.2
    Thanks & Regards,
    Sandeep

    What if the select list is not an item. Select list I am talking about is in a tabular form.Regardless of how they're generated in APEX, in JavaScript they're all DOM nodes. There are many ways of accessing the node of the required element. Consider the Items for Order... tabular form on page 29 of the Sample Application:
    var productNameLOV = document.wwv_flow.f04[0] // select list containing name of product on first order line
    var productNameLOV = $x("f04_0001") // another way of accessing the same node, using the ID attribute generated by apex_itemWe can see this using the Safari console:
    => productNameLOV = document.wwv_flow.f04[0]
        <select name="f04" id="f04_0001" autocomplete="off">…</select>
    => productNameLOV = $x("f04_0001")
        <select name="f04" id="f04_0001" autocomplete="off">…</select>Once you've got the node&mdash;however you get it&mdash;you then use the methods shown above:
    => i = productNameLOV.selectedIndex
        3
    => productNameLOV.options.text
    "Business Shirt [$50]"
    So it appears you would use:var item = document.wwv_flow.f01[i];
    var selected = item.selectedIndex;
    var selectedOption = item.options[selected].text;
    This is meaningless:...
    var my_var = document.wwv_flow.f01[i].id; // f01 is tabular column of select list
    if ($x(my_var) == 'display_value') //$x(my_var) is having return value, but i need display_value there
    <tt>$x(my_var)</tt> returns a DOM node object, whilst <tt>'display_value'</tt> is a string: they are not comparable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Filter items are not set via Redirect to a javascript function

    Hi,
    i have a page with a few filter items and a button which redirects to a javascript function. The problem is that the filter items are NULL in the called javascript function. If i do a submit via another button before then it works.
    Here the details:
    URL Target of the button: javascript:callReport('f?p=&APP_ID.:1:&SESSION.','bir.bir_api.printReportBi?pSessionId=&SESSION.&pBu=&P250_FILTER_BU.&pSupplyTeam=&P250_FILTER_SUPPLY_TEAM.&pMaxBiEff=&P250_FILTER_BI_EFF_MAX.&pGroup=&P250_FILTER_GROUP.');
    Called javascript function:
    function callReport(p_href,p_url)
      var url;
      url = document.getElementById(p_url).value;
      w = open(url,"winRep","Scrollbars=1,resizable=1,width=1100,height=800");
      if (w.opener == null)
        w.opener = self;
        w.focus();
      // wait 5 seconds before reloading
      setTimeout("waitSome()",100);
    Many thanks in advance.
    Regards,
    Martin

    Hi Martin,
    In my example I do a refresh of the report region using  adynamic action. In the report source I've set my filter item as "Page item to submit".
    To open the link for the pdf report I use a dynamic action that fires after refresh of the report region.
    That's it.
    If you want to use your callReport function and need to submit your filter items first, you could try using a ajax post to send the filter values to the database. There's a nice explanation on ajax post in this blog:
    http://apextips.blogspot.nl/2012/09/apex-ajax-basics.html
    Good luck,
    Vincent

  • How To create Library Functions for Validate Items

    Hi all,
    My form Consists data block blk_user with two items
    username and password
    Both user name and Password are required Fields.
    When user left these items Empty To show Alert
    I Created Below Procedure and Called in Form_Level ON-ERROR Trigger.
    PROCEDURE pcd_io_alert IS
         itm_name VARCHAR2(20);
    BEGIN
         IF Error_type ='FRM' AND Error_code = 40202 THEN
         Message(get_item_property(NAME_IN('SYSTEM.CURSOR_item'), PROMPT_TEXT )||' Should
    Not Be Empty');
         SET_ALERT_PROPERTY('ALT_IO',ALERT_MESSAGE_TEXT,
              (get_item_property(NAME_IN('SYSTEM.CURSOR_item'), PROMPT_TEXT ))||' Should Not
    Be Empty');
         itm_name := Show_alert('ALT_IO');               
    RAISE FORM_TRIGGER_FAILURE;
         END IF;
    END;
    It working fine.
    Could You Tell how to call or create this procedure as Library functions and call the created library in form To SHow Alert. Actually I want to create library functions to Validate and Show Alert Mesages.
    Regards
    R.MaheshBabu.

    Hello,
    Could you give Some examples or links related to how To create and call library functions For validate Items..For creation you already created one procedure and you called on error. So for creation and call it is clear. Now you are talking about validation for items. It depends on your requirement. As you check validation in items's triggers you can also check validation in function/procedure of library. You can use parameter to pass values and check the validations. And you can create the procedure/function in library like this...
    PROCEDURE My_Proc(Parameter_Name IN DATATYPE) IS
      Variables Declarations...
    BEGIN
      -- Here check the validation on the passed value.
    EXCEPTION
      -- Exception Handling part...
    END;
    FUNCTION My_Proc(Parameter_Name IN DATATYPE) RETURN DATATYPE IS
      Variables Declarations...
    BEGIN
      -- Here check the validation on the passed value.
      RETURN <ANY VALUE>;
    EXCEPTION
      -- Exception Handling part...
    END;
    Is it Possible to use system variable ':system.cursor_value' while creating PL/sql library functions?Yes, because it is clear as you used for CURRENT_ITEM like NAME_IN('SYSTEM.CURSOR_item') so you can use SYSTEM VARIABLES.
    -Ammad

  • Can we set h:outputText value= "(some javascript function value)"/

    Hi
    Can we set <h:outputText value= "(some javascript function value)"/>
    In a scenario like when user changes the item in dropdown box. label name as to change for the next text box.
    -----JSP page------
    h:outputText value="*" styleClass="mandatoryField" />
    <h:outputText value="Matching Criteria:" />
    <h:selectOneMenu id="MatchingCriteria" styleClass="dropDownMenu" value="#{OffsetTradingRuleBean.matchingCriteria}"immediate="true" onchange="unitChange()">
    <f:selectItems value="#{OffsetTradingRuleBean.matchingCriteriaMap}"/>
    </h:selectOneMenu>
    <h:outputText value=""></h:outputText>
    <h:outputText value=""></h:outputText>      
    <h:outputText id="DeminimisLabel" value="" ></h:outputText>
    <h:inputText id="DeMinimisUnit" styleClass="text" value="#{OffsetTradingRuleBean.deMinimisUnit}" maxlength="15" onchange="detectChange()" >
    <f:validator validatorId="DefaultValidator"/>          
    </h:inputText>
    <h:outputText value=""></h:outputText>
    -----Java Script-----
    function unitChange(){
         if(document.getElementById("frm:MatchingCriteria").value!="1"){
         alert('inside unitchange--'+document.getElementById("frm:MatchingCriteria").value)
              document.getElementById("frm:DeminimisLabel").value="Deminimis Dollars";
         if(document.getElementById("frm:MatchingCriteria").value!="0"){
              document.getElementById("frm:DeminimisLabel").value="Deminimis Shares";
    thanks in advance
    Rambhapuri

    balu
    actually i want to swap label name using javascript. first i will call onchange event from matching criteria dropdown box . then it will fire unitChange() function.
    then i am putting value Deminimis dollor or deminimis shares accroiding to the value which is there in dropdown.
    this value as to come in <h:outputText id="deminimisLabel" value=" should come value from java script" />
    and it should act dynamically ,. like when ever user changes the dropdown item . the corresponding name should change in lable name.
    thanks
    rambhapuri

  • Validate lookup field - require value other than first item

    I thought I would share something, and if there is a better way, please share. I have a list with a few Lookups that I wasn't able to require (since requiring them inserts the first option), and I was also not able to validate them (since they are Lookup
    columns). Nevertheless, I needed a way to ensure a value was entered with some amount of thought.
    The solution for me was to insert a Script Editor Web Part into the Default New Form and inserting a javascript snippet. On the list, on the ribbon List tab there is a Form Web Parts drop-down where the Default New Form can be found. Once you are there,
    Adding a Web Part is pretty straight forward. The Script Editor Web Part can be found in Media and Content and you will insert your code after clicking on Edit Snippet.
    The code, for me, needed to check a couple different Lookups for the Default "(None)" value when not set as a required field and block the Save and alert the user. In order to reference the correct Lookup fields I needed to use the IE Developer
    tools (click on the cog, choose "F12 Developer Tools"), on the "DOM Explorer" tab select the left-most icon for the "Select element" tool and click on the Lookup field you need to reference.
    Here is the code that worked for me:
    <script language="javascript" type="text/javascript">
    function PreSaveAction()
    var e = document.getElementById('_x002e_034_x002d_Company_e721cbe9-05ee-41cd-8227-9fc32c09e8fc_$LookupField');
    var strClient = e.options[e.selectedIndex].text;
    var g = document.getElementById('_x002E_037_x002d_Contacts_ddad3e65-bd8a-4dec-9efc-fb9416a025b1_$LookupField');
    var strContact = g.options[g.selectedIndex].text;
    if(strClient=="(None)")
    alert("***Client Field Required***\nPlease select a Client from the list or enter a New Client.");
    return false;
    if(strContact=="(None)")
    alert("***Contact Field Required***\nPlease select a Contact from the list or enter a New Contact.");
    return false;
    return true;
    </script>
    I assume you can reference as many fields as you might require. Have fun with this, and I hope the solution is easily found for the next SharePoint Dev ;-).

    Hi Alan,
    Thank you for sharing this with us, and it will help others who have the same issue.
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

Maybe you are looking for

  • My iphone 5 is not charging

    My iphone 5 is not holding a charge at all. 1 month old

  • I have a prob with my Blackberry 8700R

    hello it came with no cd rom to it every time I plug in to charge it says new hardware found please install cd or click I dont have one find it on net and wont find it were do I go to get an updated virsion for this for desk top soft ware or should I

  • A lot of problems at start up!

    Hello everyone, When I switch on my 13" Mac Pro (2011), I see two choices of drives, Macintosh HD and Recovery HD. When I pick Macintosh HD and try to key in my password, random Greek letters appear instead of the alphabet.I am not able to log in at

  • Compressor failing: "3x should not be auto-detect at this point"

    I have something that I can't seem to fix. I'm trying to render to MPEG2 but the job keeps failing with "Status: Failed - 3x should not be auto-detect at this point" error message in the status window of Batch Monitor. The logs show: <mrk tms="273146

  • Available screen size/resolution

    How do I determine the screen size/resolution that the user will be using order for my application to adapt its page size?