|
Although you've got a solution, I can't obviously see that anyone's given you an explanation why the commented out line doesn't work.
var re = new RegExp("^([1-9]|1[0-2]|0[1-9])/(\d{4})$");
In Javascript strings[^], the backslash (\ ) is used to escape the following character. As a result, your pattern actually comes out as:
^([1-9]|1[0-2]|0[1-9])/(d{4})$
That's looking for the literal character "d ", not the digits character class "\d ".
You can solve it by either escaping the backslash within the string:
var re = new RegExp("^([1-9]|1[0-2]|0[1-9])/(\\d{4})$");
or using a regular expression literal:
var re = /^([1-9]|1[0-2]|0[1-9])\/(\d{4})$/;
NB: For a regular expression literal you have to escape the forward-slash (/ ) character, since that's also used to terminate the literal.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
We've got jQuery, if I want to put something somewhere I just go
<div id=a_field_name></div> not quite as nice as
<% a_field_name %> or even
{{a_field_name}}
but has the significant advantage of being in the DOM, and is trivial yet very flexible to assign.
i.e less proper code, and HTML is always orrible anyway. That's why we write templating systems, so we can give it to someone else, right ?.
With forms, the job is even easier, and the need for YATS even less clear. Why should you need to go
<input id=a_field_name value={{a_field_name}}> when this is clearly sufficient
<input id=a_field_name>
and just as trivial as before to assign.
I also have lots of other stuff I need to do with forms, such as attaching the appropriate field handlers and selector widgets, things which should be implicit where possible but ideally can be overridden by the UI designer. I am thinking about reading my hibernate XML definition files, which I believe you can load into their own DOM and access with jquery, to decide on field length, and type and hence the handler, and "not null" etc.
There is a library here http://davestewart.io/plugins/jquery/jquery-populate/ but I am concerned that nothing has happened for 5 years. Are there any other libraries that populate, and read, form data and may be tackle assigning event handlers.
|
|
|
|
|
<title>
.style1
{
width: 443px;
height: 181px;
}
.style2
{
width: 154px;
}
.style3
{
width: 132px;
}
</form>
|
|
|
|
|
Within some javascript I want to be able to go something like
#include "file1.js"
and for that to get evaluated/included/inserted at retrieval time (but cached ideally) and recursively, i.e. for file1.js to have includes of its own, and for duplicate requests to be skipped. Just like the C Preprocessor would do.
So I am about to do precisely that, wire up cpp as a cgi and fetch my javascript through that. Using apache html SSI looks messy, or messier.
For distribution I just make a call to the webserver for my top level file and save the response.
Are there better ways of doing this ?.
modified 13-Apr-15 9:42am.
|
|
|
|
|
I set my name properly. I am at second phase of development of my first javascript. I'm ready to start factoring out some good stuff I've done and package it off nicely.
So I need to read all this
RequireJS
And I presume I then useMinify
Edit: No, there's a thing called uglify in requirejs.
Basically the answer to my question is "yes there is, we're all using requirejs. go learn".
modified 14-Apr-15 7:15am.
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) My solution to this exact problem is I created my own function to do it. RequireJS or CommonJS required you to modify your code into their module/package model. I just want to load any js file dynamically and where it is needed. It is cruel but satisfied my need.
The idea is inject the required file into the header of the page and let browser load the file and evaluate it. It works for js and css files.
var ServiceUrl = function() {
var src = document.currentScript.src;
var idx = src.indexOf("/scripts");
if (idx > 0)
src = src.substring(0, idx);
else
src = "";
return src;
}();
if (!getServiceUrl) {
function getServiceUrl() {
return ServiceUrl;
}
}
if (typeof (include) == "undefined") {
function include(url, type, cb, asIs) {
asIs = asIs || false;
cb = cb || null;
if (!url) {
console.log("No file specified to be loaded.");
return;
}
if (!asIs)
url = getServiceUrl() + url;
var alreadyLoaded = false;
if (type.indexOf("javascript") > 0) {
var sc = document.scripts;
var scExists = false;
for (var i = 0, len = sc.length; i < len; i++) {
var src = /src="(.*?)"/.exec(sc[i].outerHTML);
if (src && src.length > 0) {
if (src[1] == url) {
scExists = true;
break;
}
}
}
if (!scExists) {
var el = document.createElement('script');
el.type = type;
el.src = url;
}
else
alreadyLoaded = true;
}
else {
var ss = document.styleSheets;
var cssExists = false;
for (var i = 0, max = ss.length; i < max; i++) {
if (ss[i].href == url) {
cssExists = true;
break;
}
}
if (!cssExists) {
var el = document.createElement("link");
el.href = url;
el.type = type;
el.rel = "stylesheet";
}
else
alreadyLoaded = true;
}
if (el) {
if (typeof (cb) == "function") {
el.onload = cb;
}
var head = document.getElementsByTagName('head')[0];
head.appendChild(el);
}
if (alreadyLoaded) {
if (typeof (cb) == "function") {
cb();
}
}
}
};
|
|
|
|
|
|
Need a lot more info.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have an application deployed on one server and from this server I want to pop up a new window, which will open a asp.net page deployed on any other server, using window.open() and I want to pass parameters to this pop up window. I don't want to pass parameters through URL. Need some way to pass parameter in a hidden or more secure way.
Can anyone suggest how this can be done.
Thanks in advance.
|
|
|
|
|
|
first we r finding the grid
like this
var grd=document.getElementById("GridView1");
after how can we get a selected row value in grid using javascript
|
|
|
|
|
|
hi everyone can anybody help me for below functionality
i have button and grid on webform1 and i need to transfer data from gridview(seleted row) to webform2 using javascript.
|
|
|
|
|
You can use Ajax[^]... Web Sockets[^]... LocalStorage[^] and many other options to share your data from one form to another.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
- On click of your button, call a javascript function.
- Get the gridview row data in Javascript variable (probably from dom attribute).
- Put the data in Webform2 url query string.
- In your webform2, read the data from query string.
Hope this helps.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
i have a file,file format is CMYK(Cyan,Magenta,Yellow,Black),file have 7 layer include background,i want to multiply layer by Formula,
layer 1(cmyk)---C1,M1,M1,K1
layer 2(cmyk)---C2,M2,M2,K2
Merge all layers ways:
Layer 1 (C1, M1, Y1, K1) and layer 2 (C2, M2, Y2, K2) and Layer 3 (C3, M3, Y3, K3), ......
1.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1>= C2, C = C1 + C2-2 * C1 * C2 / 100 + C1 * C1 * C2 / 10000
B. If C2 > C1, C = C1 + C2-2 * C1 * C2 / 100 + C2 * C2 * C1 / 10000
then Layer 1 and Layer 2 merged into layer 1
2.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1 >= C3, C = C1 + C3-2 * C1 * C3 / 100 + C1 * C1 * C3 / 10000
B. If C3 > C1, C = C1 + C3-2 * C1 * C3 / 100 + C3 * C3 * C1 / 10000
then Layer 1 and Layer 3 merged into layer 1
3.
Layer 1 and Layer 4 identical coordinate positions, with C for example
A. If C1 >= C4, C = C1 + C4-2 * C1 * C4 / 100 + C1 * C1 * C4 / 10000
B. If C4 > C1, C = C1 + C4-2 * C1 * C4 / 100 + C4 * C4 * C1 / 10000
then Layer 1 and Layer 4 merged into layer 1
........
pls help
|
|
|
|
|
I have a html page where I am loading PDF file using Div.
I need to refresh that Div only once without refreshing whole page using javascript or jquery.
Need urgent help.
Thanks.
|
|
|
|
|
jQuery provides the load method[^]:
Load data from the server and place the returned HTML into the matched element.
$("#result").load("ajax/test.html");
However, you cannot display a PDF file directly within a <div> tag. You would need to use an <iframe> , or some other PDF viewer control.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
+5
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How to make a Content Slider in JavaScript with all the function eg play, pause, replay, seek on the slider for moving back and front, sync slider with audio and contents
|
|
|
|
|
Content slider and play pause buttons are totally different things. You are combining a media player with a content slider.
Do it yourself, using jQuery players[^], and a content slider[^].
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Then remove the jQuery from search box, and search for JavaScript version. What prevents you from doing so?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Normally JSON data is fetched in the following form from Web API etc.
[
{"name" : "Steve", "Age": 76}, {"name": "Jeremy", "Age": 43}
]
You can see that "name" and "Age" is repeating with every column. But I've seen a service getting data in this fashion. Which really shorten the JSON object something like that.
[
columns: {"name", "age"}
data: {"Steve",76},{"Jeremy",43}
]
How to do it?
|
|
|
|