IsNumeric? Includes Object.focus() Workaround
Nov 21, 2005
I was having trouble getting the object.focus() method in IE and in FF working, so came up with this workaround.
What I wanted to do was check if a textfield was numeric, if not, inform the user then select the text and set the focus back to the field.
Sound simple? object.focus() simply doesn't work in firefox or (I've been informed) IE.
Solution:
Instead of checking when the field losing focus (onblur), check when the next field receives focus (onfocus). Then call a function that gets the element index of the object, and use that index to check the element above it. Difficult to explain.
Here it is...for the textfield you want to check, put this into the next form object after it onfocus="checkNum(this)"
then put this script in the header section...
function checkNum(obj){
var idx;
//get object index
for(idx=0;idx<document.forms[0].elements.length;idx++){
if(document.forms[0].elements[idx].name==obj.name){
break;
};
};
//check for numeric
if (isNaN(document.forms[0].elements[idx-1].value)){
alert('Value must be a number!');
document.forms[0].elements[idx-1].select();
document.forms[0].elements[idx-1].focus();
};
};
But there is one problem!!! As I just found out.
If the next field is a group option, they all have the same name and so this will not work.
for those that do not know, the function isNaN is a js function that is the same as the vbscript equivalent IsNumeric.
isNaN means isNotaNumber.
Hope this helps, I know the focus() failure of JS has been the bane of many coders.
View 4 Replies
ADVERTISEMENT
Jun 2, 2010
I'm currently constructing a javascript "terminal" on a site I'm building so that I can test objects and functions outside of the web developer terminal in google chrome.
Given that I have active javascript defining an object called item, typing item in the chrome terminal returns Object and goes on to list the properties of item.
Moreover, I can define a function in the terminal like this: function(x) { return x }, and then function(item) will return Object and list the properties. However, if I use form data and user input in the place of the argument, the datatype becomes a string and not an object, so typing item in the form and clicking a button that performs function(document.form.text.value) returns the string item and not Object.
Is there any way to convert this primitive string to an object so that I can then iterate through properties, and so on?
View 2 Replies
View Related
Aug 13, 2003
is there any other way to include a js file other than this:
<SCRIPT SRC="js.js"></SCRIPT>
i want to do it because i need to put a variable in place of js, so it would be:
res = screen.width;
<SCRIPT SRC="res.js"></SCRIPT> where variable was determined earlier.
but i dont think i can do that
View 2 Replies
View Related
Feb 6, 2007
we probably all know the problem that select boxes under IE are always
overlap DIV layers. Afaik there are two workarounds:
1. hiding the select box
2. IFrame beneath the DIV layer
But I don't know how to do that.
We want to show a DIV layer as tooltip.
The DIV layer has no defined size (neither a width nor a height
attribute). The size depends on the text the user defined for the tooltip.
My questions:
1. How can I know when the tooltip is 'over' a select box, so I can hide it.
2. How can I define an IFrame that has the same size as the tooltip,
when I don't know the tooltip's size?
View 1 Replies
View Related
Jun 13, 2010
what is the advantage of using javascript files in an includes folder rather than on page?So for example i have a javascript validation on my page, does it make a difference to the way it is execute compared to if i referenced to it rather than having the full file in my page?
View 1 Replies
View Related
Jun 18, 2001
Alright, my site is curerntly using server side includes (hoping to switch it all over to PHP soon). What I would like to do is include a different file depending on screen resolution. Does anyone know how to do this?
View 5 Replies
View Related
Mar 16, 2007
I have an onchange method for a select box that goes something like
this (the select is in a form named aForm):
function page_on_change() {
pageElement = aForm.my_page_id;
aForm.nav_page_name.value =
pages[pageElement.options[ pageElement.selectedIndex ].value];
var si = pageElement.selectedIndex;
for ( i = 0 ; i < pages.size ; i++ ) {
document.getElementById("id_" + i).style.display='none'
}
document.getElementbyId("id_" + si).style.display='none'
}
IE fails on the statement:
document.getElementbyId("id_" + si).style.display='none'
and says it doesn't support this property.
What is the workaround?
View 4 Replies
View Related
Nov 16, 2006
Has anyone experienced this (and found a solution)?
I have five files: a .htm that invokes four .js include files.
Only the first alert in the first include is displayed.
This only happens when I run on a client's corporate server.
I have no problems on a laptop connected to the network
or on my home PC. Any ideas? Code:
View 7 Replies
View Related
Apr 16, 2004
I have client that has 5 versions of the same site located in web viewable root folders on his server. Aside from a few minor differences such as prices, download url's and a few text and image differences, they're the same.
Just wanted to get some opinion as to how many javascript includes I can, or should, use on the site pages or if there are any strong opinions on not doing it this way.
I'd like to place a set of javascipt files in a folder within each site, then have all pages in each site call to their specific include folder. This way I'll be able to use a single set of DW templates to manage the content on all the sites.
I can't convert to php, use ssi nor create a dynamic solution since the sites are already live and rank well in the search engines, The content I'll be wrapping in the includes is not important search engine text content.
View 1 Replies
View Related
Jan 15, 2010
use something like this to workaround the lack of a "Select All Friends" button for Facebook groups, events and pages?
<html>
<frameset cols="25%,75%">
<frame name=inviteall src="inviteall.html">
<frame name=main src="http://www.facebook.com">
</frameset>
[Code]...
This bit isn't mine, I found it. You normally have to use this by copying it and then pasting it into the address bar when you are on the "Select Friends" screen.
View 3 Replies
View Related
Feb 1, 2009
I don't know why this function "IsNumeric" is not working code...
View 1 Replies
View Related
Dec 9, 2010
I have developed a widget. I am using the jquery core api. Im having a problem when the widget is used in a weebly site. I know weebly uses prototype and I am using the workaround:
var $j = jQuery.noConflict(); however there is still a clash of some sort. I think every prototype.js function is being called or something because the page is taking a long long time to load as there are many requests being made which look like this:
[Code]...
View 3 Replies
View Related
Dec 1, 2006
This is IE issue only. Firefox and mozilla doe not have this problem.
td cell in a table with a title which includes '-'(dash). If I add a
dash between Time-Time. IE intrepets as new line os somethig and the
title is displayed in 2 line like:
Time-
Time
instead of Time-Time.
Below is snippet of the code...
View 3 Replies
View Related
Jul 20, 2005
I was calling a function in a js file from an image onClick event, but
someone still using Netscape 4 (!) complained that it didn't work. I
read that img onClick doesn't work in Netscape 4, so swithced it to
"javascript:show(...);" and the code works, but I read in this group
that it was not wise to do that, here's the working version, using the
not recommended approach:
<a href="javascript:show('art_2.jpg',÷»',ò^');" target="_self">
I'd appreciate any suggetions that will let me call the "show" function
from an onClick image event that will work in most IE/Netscape 4+ browsers.
View 2 Replies
View Related
Jun 4, 2009
I dynamically make a textarea and save the text, but when I try to output it with javascript, the newlines screw it up... if you don't understand what i mean, here is some code:
Code:
With that newline in javascript, the javascript throws an error. i am working in jsp, so how would i change the text that is put into the textarea with javascript without changing the newlines?
Here is how i try changing it:
Code:
But it doesnt change anything,
View 1 Replies
View Related
Sep 24, 2010
I have created a global navigation includes document. Unfortunately the drop down menus that are part of the navigation aren't working. They worked fine when they were part of the page, but now that they are separated from the page as includes the drop down menus don't appear in my test site (posted to a web server). All other content in the includes file appears and works.
View 1 Replies
View Related
Sep 24, 2010
I've got a global navigation document with drop down menus created using javascript saved as includes. These are posted to a web server and the pages that reference the includes display the graphics and some of the links, but not the drop down menus. They don't appear on roll-over.
View 1 Replies
View Related
Mar 23, 2007
mailto protocol and Notes v6.5.5 which duplicates the address in the To: field (not a valid email address) and/or posts form data in the To:, cc, or Subject: field rather than in the body of the email where it belongs. I created an entire site relying on the mailto: protocol to submit requests. (Can't use either server side apps or cgi email. Don't ask - it's a long and rediculous story.) Anyway, then we got the new release of Notes and the whole thing has been rendered useless for request submissions.
Is it possible to write a script that will duplicate the mailto: form action and keep it client side? Big hurdle is that it has to pull info from all types of form elements, just like the mailto: protocol does with email clients that actually support it properly.
View 4 Replies
View Related
Aug 30, 2010
I am doing some maintenance work on a classic asp web page that displays product information. I am changing how the page looks up the available quantities for the various sizes. The old method used several SQL queries to determine the number of sizes and available quantities and then used those results to build a table on the fly on the page.
My modification consists of a web service that consolidates product size availability from three different sources and delivers the data via an XML formatted return. I have also added DOM tags in the table that is built on the fly that identify each entry with the product id and size. So, for a product that has an ID of "P12345" and a size of "XXL," that corresponding cell in the table gets an id tag of "P12345_XXL."
My jQuery update statements worked just fine using this approach until the sizes included decimal numbers. My example for this is shoe sizes. A size represented by an integer (6,7,8,...,15,16,17, etc.) works fine. A half-size represented by a decimal (6.5, 7.5, 8.5,...) does not. Even though the period is contained within a string value, jQuery doesn't seem to be able to match the value with an id tag - and yes, I have verified that the two (the string that I am giving to the jquery select and the actual tag) do indeed match.
So far, the only work-around that I have come up with is to multiply numeric sizes by 10 and parse as integer values. Is this a "known issue" and is there a more elegant solution topursue?
View 2 Replies
View Related
Aug 18, 2010
I'm currently making a web application which needs to be fully compatible with iPad. The functions I've implemented so far work perfectly on Firefox, Internet Explorer and other browsers. However, the iPad itself responds a bit different. After a certain action, I want to put focus on a textfield with the help of Javascript. Again, this works perfectly with the normal browser, the iPad browser however seems to be blocking the focus. The reason I'm not posting any code is because it's basically irrelevant. All I do is:
[Code]...
View 1 Replies
View Related
Jul 23, 2005
Is there a reason why setting focus to a textbox input, also gives
focus to a submit button on the page, to where if you click enter in
the text box, the submit button will be clicked.
View 2 Replies
View Related
Mar 29, 2011
The default behaviour of focus() method is displaying the cursor at start of the char(In FF focusOffset is 0(zero) and anchorOffset is 0(zero)). I need to display the focus at end of char after calling focus() method.
View 5 Replies
View Related
May 9, 2010
I think the problem is cause by my lack of understanding of how the browser (firefox 3.6.3) handles focus.A simplified version of my problem is:I've defined the function
function two_focus()
{
document.getElementById("two").blur();
[code]....
View 6 Replies
View Related
Jul 23, 2005
I'm trying to do some javascript form validation and I've discovered a
rather difficult situation to handle with IE.
Let's say there's a form with three input fields named "name",
"method", or "length". Whenever my javascript tries to access the
form's name or length, and the form happens to have input fields named
"name" and "length", I'm actually accessing the input fields and there
seems to be no way to access those properties of the form.
I have an easy workaround for form.length, so there's no need to give
me a workaround for that one, but there's a bigger issue with fields
like name, method, action, etc.
For example, using document.forms[0].name to get the name of the form
seems to map to document.forms[0].elements["name"] istead of the
actual name of the form. Is there a work around for this? I am
writing some generic form validation code, and I can't expect the
person implementing my form validation code to avoid using "name" and
"length" as names for their form fields.
View 1 Replies
View Related
Apr 10, 2011
Is there a way to set the focus on a form field without using focus()? I use ajax to build the form and if I try to set the focus using focus() an error is generate because of the form hasn't been built by ajax. So, it would be nice if I could set the focus() as I built the form.
View 4 Replies
View Related
Apr 3, 2011
im working with execCommand and trying to make a function to insert a youtube video into a content editable div with execcommand inserthtml. Now this works with every other browser except, OMG IE. now i am trying to use pasteHTML(), found that some people have gotten it to work, for its part but for some reason it is not working
[Code]....
View 3 Replies
View Related