Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:48:16+00:00 2026-06-16T04:48:16+00:00

I have this html code : <div id=jiraTicketAccordion> <div> <h3><a href=#>key</a></h3> <div> <form> <div

  • 0

I have this html code :

<div id="jiraTicketAccordion">
 <div>
   <h3><a href="#">key</a></h3>
   <div>
     <form>
        <div id="jiraTable">
      <table>
        <tr>
           <td class="label"><label for="arrival">ARRIVAL :</label></td>

           <td><input type="text" name="arrival" class="arrival"  
                     onblur="checkTime(this.value);"/></td>

           <td class="label"><label for="newarrival">NEW ARRIVAL :</label></td>

          <td><input type="text" name="newarrival" class="arrival"  
                     onblur="checkTime(this.value);"/></td>

        </tr>
      </table>
     </form>
    </div>
  </div>
</div><!-- end of accordion div -->

As you can see I have javascript function checkTime for onblur() event in that input box.

Earlier I had that text box with a unique id so I used document.getElementById for accessing it in my javascript function.

But now as there are many of accordion with same structure so I don’t want to use unique ids for as there can be a large number.

So now I have a class for all those text boxes that require that validation.

But now I have to change my javascript functions where ever I used document.getElementById.

I know we can select elements by class in jquery, I also tried that but didn’t get required results.

This is what I have tried in jquery:

function checkTime(dateTime){
    alert("inside  check time");
    var errorMsg="";
    regex = /^(\d{2})\/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\/\d{2} \d{2}:\d{2} [AP]M$/;
    if(dateTime != ''){
    if(!regex.test(dateTime)){
             errorMsg = "Please enter date and time in the format: \n dd/MMM/YY HH:MM AM/PM";
         alert(errorMsg);   
    //how to make the element that called this function to 
    //blank value it it failed validation
    }
     }
}   

I wanted to access the element that called this method, so that I can manipulate that text box value.
And also I want to access other element by class in same accordion within that checkDate function.

I don’t know how to make the text box vaalue to blank it it failed validation.

Earlier when I was having id ,I was doing it as :

document.getElementById('arrival').value='';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:48:17+00:00Added an answer on June 16, 2026 at 4:48 am

    Shortest path from your current code is just passing the element instead of the value:

    onblur="checkTime(this);"
    

    Then on your function:

    function checkTime(el){
        var dateTime = el.value;
        // rest of function
    }
    

    Personally, I’d avoid using inline event handlers like onblur="...", and use addEventListener to bind the handlers directly from JavaScript. That would be one step further towards decoupling logic, structure and presentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a look at this HTML code: <div class=overlay> <a href=#>1</a> <a href=#>1</a> <a
I have this code: HTML <div class=box_meteo> <div class=box_meteo_pulsanti> <a href=javascript:void(0); class=box_meteo_pulsante id=meteoButton1>Link</a> </div>
I have this HTML code : <div class=field> <input type=hidden value= name=a id=a> <input
I have this HTML code: <div id=note_list> <div class=note> Text 1 <a href=>X</a> </div>
I have this html code <div id=b_container> <div id=b_header> <div class=header_left><a href=#>link 1 </a></div>
I have this html code: <div id=menu> <ul id=menuFuncionalidades> <li> <div class=menuFuncionalidades_categoria> <a href=/sttenterprise/>Index</a></div>
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have this html code: <div class=action> some_text <a class=delete_action name=q1>some</a> </div> <div class=action>
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.