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 7617477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:09:35+00:00 2026-05-31T03:09:35+00:00

On checking a field against validations, if validation fails , a pop up window

  • 0

On checking a field against validations, if validation fails , a pop up window is opened.Now when i close the pop up the pop up should return the focus to the last element(in case more than one validation fails for more than one text field). any suggestions ?
My code is:-

 function submitformFinal(frm) {
 var message;


 var inputs = frm.getElementsByTagName("input");

     for (var i=0; i < inputs.length; i++)
     {
         if (inputs[i].getAttribute('type') == 'text')
         {

             if(!checkSpecialChars(inputs[i].value))
             {
                  message =  " Special characters found in element = '";
                  message += inputs[i].getAttribute('name') + "'\n";
                  // alert(message);
                  // createPopup(message);

                  MyPopUpWin(message);
             }
        }
    }    
    // return true;
 }

function checkSpecialChars(fileOnlyName)
{
    if ((/[^a-z0-9\.]/gi).test(fileOnlyName)) {

        return false;
    }
    return true;
}

function MyPopUpWin(message) {
    var iMyWidth;
    var iMyHeight;
    //half the screen width minus half the new window width (plus 5 pixel borders).
    iMyWidth = (window.screen.width/2) - (75 + 10);
    //half the screen height minus half the new window height (plus title and status bars).
    iMyHeight = (window.screen.height/2) - (100 + 50);
    //Open the window.
    var generator = window.open();
    document.onclick=function()   {
        try{
            generator.focus();
            return false
        }
        catch(e){}
    }

    generator.document.write('<html><head><title>Pop uP</title>');
    generator.document.write('<p style="color:#C52B27;">');
    generator.document.write(message);
    generator.document.write('</p>');
    generator.document.write('</head><body>');

    generator.document.write('<a href="javascript:self.close()"><img src="/img/save_orange.gif" border=0">  <\/a>');
   generator.document.write('</body></html>');
   generator.document.close();
}
  • 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-05-31T03:09:36+00:00Added an answer on May 31, 2026 at 3:09 am

    In your code, use:

    MyPopUpWin(message); <- existing line
    inputs[i].focus()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting what would appear to be a simple pre ajax-post validation against a short
POST #1 How can I validate this simple form (checking for empty field strings)?
I am validating a form (checking if field are empty etc and at the
SQL Server 2005. Is there a sql query that will return a text field
I have a contact form and I handle errors by checking each field one-by-one
I'm using Dojo's behavior functionality to add events. I'm checking a text field to
Checking the HTML source of a question I see for instance: <a id=comments-link-xxxxx class=comments-link>add
Checking to see if __name__ == '__main__' is a common idiom to run some
Checking few RDBMS I find that things like SELECT COUNT (a), SUM (b) FROM
Checking if a user input is a valid date or a valid date +

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.