Right now...the dateISO method is as follows:
dateISO: function(value, element) {
return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
},
but ive noticed that when a user enters something like 1991-99-99 it sees it as a "valid date" when it obviously is not. How would i change this code to have it check if the month is 01-12 and the date is 1-31?
Case One:
new Date(Date.parse("Jul 8, 2005"));
Output:
Fri Jul 08 2005 00:00:00 GMT-0700 (PST)
Case Two:
new Date(Date.parse("2005-07-08"));
Output:
Thu Jul 07 2005 17:00:00 GMT-0700 (PST)
Why is the second parse incorrect?
Hello,
I am designing a web site that plays music. The music player itself will be in a separate window along with the now playing list. I want to be able to refresh the now playing list when a new song is added to it from the main window. Essentially I need to figure out how to communicate between the two windows. I was only able to find one plugin on line that defines the player page as a child of the main page but then this reference would be lost after the parent page i.e my main page was refreshed. So this was not very useful to me and I'm kinda lost atm.
Any help is greatly appreciated
PS: here is the link to that plugin (http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/)
Hi! A few hours ago, I was instructed how to style a specific textarea with JS. The following piece of code (thanks again, Mario Menger) works like a charm in Firefox but unfortunately nothing happens in Internet Explorer (7 tested only so far).
var foo = document.getElementById('HCB_textarea');
var defaultText = 'Your message here';
foo.value = defaultText;
foo.style.color = '#888';
foo.onfocus = function(){
foo.style.color = '#000';
if ( foo.value == defaultText ) {
foo.value = '';
}
};
foo.onblur = function(){
foo.style.color = '#888';
if ( foo.value == '' ) {
foo.value = defaultText;
}
};
I've already tried to replace 'value' by 'innerHTML' (for IE only) but to no effect. Any suggestions? TIA
I would like to convert a floating point variable to a string without losing any precision.
I.e. I would like the string to have the same information as my floating point variable contains, since I use the output for further processing (even if it means that the string will be very long and readable).
To put this more clearly, I would like to have functions for cyclic conversion
var dA = 323423.23423423e4;
var sA = toString(dA);
var dnA = toDouble(sA);
and I would like dnA and dA to be equal
Thanks
PS: Sources on the internet usually talk about how to round strings but I have not found information on exact representation. Also I am not interested in Arbitrary Precision calculations, I just need double precision floating point arithmetic.
I am using google maps api v3 and have an array of arrays object:
MVCArray.<MVCArray.<LatLng>>
I want to iterate over this. I see that MVCArray has a method forEach which uses a call back, but I have no idea how to use this (I haven't done much js). The api defines this method as follows:
forEach(callback:function(*, number)))
Could somebody please show me an example of how to use this given an MVCArray of MVCArrays?
why does the following js expression:
"test1 foo bar test2".replace(/foo.bar/, "$'")
result in the following string?
"test1 test2 test2"
is the $' in the replace string some sort of control code for including everything after the match???
this behavior was screwing with me most of the day. can anyone explain this?
thanks a lot
ps- this is the case in all browsers i've tested
I'm retrieving an array of objects from a hidden html input field. The string I'm getting is:
"{"id":"1234","name":"john smith","email":"[email protected]"},{"id":"4431","name":"marry doe","email":"[email protected]"}"
Now I need to pass this as an array of objects again. How do I convert this string into array of objects?
I need a way to turn my 2 character string dates (i.e. '04/10/2010' & '05/24/2010') into an integers in jquery to see if one is greater than the other. If the user enters an end date that is less than the begin date I need to popup an "invalid date range" error.
I am storing a JSON string in the database that represents a set of properties. In the code behind, I export it and use it for some custom logic. Essentially, I am using it only as a storage mechanism. I understand XML is better suited for this but I read that JSON is faster and preferred.
Is it a good practice to use JSON if the intention is not to use the string on the client side?
I need a way to turn my 2 character string dates (i.e. '04/10/2010' & '05/24/2010') into an integers to see if one is greater than the other. If the user enters an end date that is less than the begin date I need to popup an "invalid date range" error.
I'm trying to understand if I can debug a stand alone .js file which doesn't interact with browser. Is there any way to just load it and debug or I will be forced to encapsulate it into html file?
I was adding recent videos gadget on my blog. In that widget i was supposed to add this line
<script src="/feeds/posts/default?orderby=published&alt=json-in-script&callback=showrecentpostswiththumbs">
also, i added another script which was having the method showrecentpostswiththumbs [ used in callback ]. Please let me know what does above syntax do?
Hi, I'm using CurvyCorners to make my corners curvy in IE, only thing is that when it reads the CSS it takes all the webkit properties and shows me an alert curvyCorners.alert("No object with ID " + arg + " exists yet.\nCall curvyCorners(settings, obj) when it is created.");.
How can I just set this if statement to do nothing?
if (j === null)
do nothing(); //but in real script
Thanks :)
Ok, so I have a "navigation" div and "content" div.
When something on the navigation is clicked, I fade in the content div with the new data.
Now, I would like to have the old data returned when the user hits the "back" button on his/her browser, but I'm having a hard time doing this.
I know I can set the content to be a named anchor, so they stay on the same page with a breadcrumb trail. However, that's as far as I get. Can I listen for a back button click? Can I set content to display when a certain anchor name is reached?
Thanks in advance for your help, SO.
Hi this is my pice of code:
<div style="overflow: hidden; width: 445px;">[IMG]http://i29.tinypic.com/mydog.png[/IMG] tak si to http://i29.tinypic.com/mycat.png Lorem ipsum loremai <img width="15" border="0" align="middle" src="images/smejo.gif" valign="middle"/> <img src=http://www.example.com/index.png alt> <img src="http://www.example.com/index.png" alt> <a href="#reakcia" title="reagovat na temu"><span class="poradna-tl-reaguj"><reaction> </span></a></div>
</td> </tr><img src=http://www.example.com/index.png alt><img src="http://www.example.com/index.png" alt>
and i need regex pattern to replace ONLY text image links with image without touch of inner url tags.
But i can't use "Lookbehind" or possessive quantifiers because JS don't support them=/
So i want to catch only "http://i29.tinypic.com/mydog.png" and "http://i29.tinypic.com/mycat.png".
I using array method to replacing (will be greasemonkey script.)
Many Thanks
I have a very simple function that takes a list of comma separated (x,y) points and imports them into a graph. I have FF, Chrome and IE8 installed. I use IETester to test for IE6 and IE7.
// Import Data
this.Import = function(data) {
alert("Data in: "+data);
var d;
// Make sure the first and the last are start/ending parenthesis
if ( (data[0] != '(') || (data[data.length-1] != ')') ) {
alert("After if: "+data[0]+" "+data[data.length-1]);
return false;
}
...
In Chrome, FF and IE8, I don't see the "After if:" alert.
In IE6 and IE7, I see the following two alerts:
Data in: (52,16),(100,90)
After if: undefined undefined
The "Data in" alert matches in all browsers.
Any ideas?
I'm working on a simple subtraction problem, but unfortunately it keeps returning NaN
Here is the function
function subtraction(a, b) {
var regexp = /[$][,]/g;
a = a.replace(regexp, "");
b - b.replace(regexp, "");
var _a = parseFloat(a);
var _b = parseFloat(b);
return _a - _b;
}
And here is how I'm calling it.
txtGoodWill.value = subtraction(txtSellingPrice.value, txtBalanceSheet.value);
The numbers that get submitted to the function are ONLY Currency (IE: $2,000 or $20, etc)
Now I know that I cannot subtract numbers with a $ or a ,, but I can't for the life of me figure out why they are getting evaluated in the equasion.