How can I match the following pattern?
"anything123.anythingelse"
Alphanum of any length, with exactly 1 "." in the middle, and then alphanum of any length?
Thanks.
I have a table with 5 rows and 2 columns. Each cell contains a text box. I want to show error if one of the text boxes in each column is empty. I want both text boxes in a row shld be filled or both shld empty.
How can i do this via Asp.net validation controls?
Hi, I am using this code to refresh the data inside of the div:
<script>
$(function() {
$("#refresh").click(function() {
$("#new").load("/new.php")
})
})
</script>
Except it loads the who page inside of the div, instead of just the information that is inside of the div.
How do I make it refresh only the data that is inside of the div? Is there a way of doing it other than putting the information for that div in a seperate page?
Hello,
My string contain a lot of HTML entities, like this
"Hello <everybody>" there
And I want to split it by HTML entities into this :
Hello
everybody
there
Can anybody suggest me a way to do this please? May be using Regex? Thanks so much.
Here is my function:
function processCheck() {
var numberClicked = 0;
var frm = document.getElementById('form');
for (var i=0; i<form.elements.length; i++) {
if (frm.elements[i].checked)
numberClicked++;
}
if(numberClicked != 8)
alert('Must choose 8 Teams');
else
frm.submit();
}
My forms name is 'form', here is my input:
echo "<input type='button' name='submit' value='Update' onclick='processCheck()' />";
When i click the button and there is anything but 8 boxes selected it displays the alert, if there is 8 boxes it does nothing (<-- The problem). I have the form action set to another page.
The following code works:
$(".valClear").each(function () {
if ($(this).val().indexOf(".png") == -1) {
$(this).val('');
}
});
However this doesn't (the value is removed even if it contains .png or .jpeg), what am I doing wrong?
$(".valClear").each(function () {
if (($(this).val().indexOf(".png") == -1) || ($(this).val().indexOf(".jpeg") == -1)) {
$(this).val('');
}
});
I'm having a Firefox-specific issue with a script I wrote to create 3d layouts.
The correct behavior is that the script pulls the background-color from an element and then uses that color to draw on the canvas. When a user mouses over a link and the background-color changes to the :hover rule, the color being drawn changes on the canvas changes as well. When the user mouses out, the color should revert back to non-hover color.
This works as expected in Webkit browsers and Opera, but Firefox chokes on it if mouseout is triggered and no mouseover event follows it. This is easier to see than for me to describe, and it's too much code to post here, so here is a link:
http://www.robnixondesigns.com/strangematter/
I have classes looks like below:
function Student(name, surname, lossons){
this.Name = name;
this.Surname = surname;
this.Lessons = lessons;
}
function Lesson(){
this.Name = name;
this.studentCount = count;
}
And i want to write ToString method to them. But i don't want to write and add them one by one. Is there any way to do this like reflection in C# or Java ?
Any help would be appreciated...
Hi,
I have the following code. I expected to see "archive" object on my firebug console, but I see Window object. Is it normal?
var archive = function(){}
archive.prototype.action = {
test: function(callback){
callback();
},
test2: function(){
console.log(this);
}
}
var oArchive = new archive();
oArchive.action.test(oArchive.action.test2);
Hi All,
Is there a way in any browser to add/remove class names? For example, if I have a div with class names and I just want to remove/add 'name2' is there a way to do that?
Thanks,
rodchar
var exampleURL = '/example/url/345234/test/';
var numbersOnly = [?]
The /url/ and /test portions of the path will always be the same.
Note that I need the numbers between /url/ and /test. In the example URL above, the placeholder word example might be numbers too from time to time but in that case it shouldn't be matched. Only the numbers between /url/ and /test.
Thanks!
Hello
So i have this:
yes: <input type="radio" value="Y" id="SCvoteY" name="vote"></input> no: <input type="radio" id="SCvoteN" value="N" name="vote"> </input>
How do i write that it should transfer name="vote" data ? #vote doesnt work, .vote either (guess it cause thats for class and ID) but what about name then?
function DoSCInsert(){
$("#SCres").html("please wait..");
var nocache = '0';
var data = { fID : $("#fID").val(), vote : $("#vote").val(), comment: $("#comment").val(), nocache: nocache };
$.get('insertSC.php', data, onSCInsertComplete);
}
And how do i shorten this, ive heard that you can you a function in jquery called serialize to pass strings but can you(if you know how) show example by this script how to pass it like this one does?
Is it possible to get the source of the current HTML document, exactly as it was loaded, in text form? (i.e. not the "Generated source" after parsing and DOM manipulation.)
Note: Issuing an extra AJAX request to retrieve the HTML page again is not an option in this case: The document could have changed.
I was trying to remove some items from an array ,
Array.prototype.remove = function(from, to)
{
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var BOM = [0,1,0,1,0,1,1];
var bomlength = BOM.length;
for(var i = 0; i < IDLEN ;++i)
{
if( BOM[i] == 1)
{
BOM.remove(i);
//IDLEN--;
}
}
RESULT IS
BOM = [0,0,0,1];
expected result is
BOM = [0,0,0];
its looks like i am doing something wrong , Please help me.
Thanks.
I have this code:
document.getElementById('root').style.left = '<?php echo $page_position[$info["os"]][$info["browser"]][0]; ?>';
document.getElementById('root').style.top = '<?php echo $page_position[$info["os"]][$info["browser"]][1]; ?>';
Why won't this work like this?
Can anybody point me in the right direction?
EDIT:
<?php echo $page_position[$info["os"]][$info["browser"]][1]; ?>
echoed "top:300px;"
Sorry guys, very stupid error of mine :/
This seems to work on everything but explorer:
NextButJar.addEvent("click", function() {
if (this.disabled == true) {
alert("Please view all tabs first!");
return;
}
});
Any help welcome
function SimpleSymbols(str) {
var letter =['a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var newstr = "";
for (var i = 0; i<str.length; i++){
if (str.charAt(i).toLowerCase() in letter){
newstr += "M";
}
else{
newstr += "X";
}
}
return newstr;
}
If str is "Argument goes here" it returns XXXXXXXXX. WHy doesn't it return MMMMMMMMMM?
sometimes we loss the new keyword when define new object,
obj = new Clazz(); //correct
obj = Clazz(); //wrong, but no syntax error, hard to debug.
I want to write a function to help me create Class and make it new safe.
var Class = function(constructor){
//when constructor
// if not call by new
return new constructor();
// else
constructor();
}
var MyClazz = Class(function(name){
this.name = name
}, SuperClazz1, SuperClass2 )
MyClazz.extend({
show: function(){console.log(this.name)}
})
obj1 = new MyClazz();
obj2 = MyClazz();
// obj1 should same as obj2
Is it possible, any exists module?
I'm thinking whether it makes sense in order to increase the speed of the website to do some strategy of caching the js files that are being included ?
one idea that I have is to do something like this:
[OutputCache(Location = OutputCacheLocation.Any, Duration = 3600)]
public JsController : Controller
public ActionResult JQuery()
{
//I would have a ascx with the entire jquery script inside
return View();
}
and on the site.master:
<%=Html.RenderAction("JQuery","JsController");
How do I retrieve the month from the current date in mm format? (i.e. "05")
This is my current code:
var currentDate = new Date();
var currentMonth = currentDate.getMonth() + 1;
Hi,
I was wonder if you can delete a cookie at the beginning of the next day.
Lets say I log in to a website at 1:30pm and use it again throughout the day but at midnight or 1 minute past, in the new day, the cookie is removed.
Many thanks for any help,
C
$('#customerAddress').text().replace(/\xA0/,"").replace(/\s+/," ");
Going after the value in a span (id=customerAddress) and I'd like to reduce all sections of whitespace to a single whitespace. The /\s+/ whould work except this app gets some character 160's between street address and state/zip
What is a better way to write this? this does not currently work.
I'm writing the JS for a chat application I'm working on in my free time, and I need to have HTML identifiers that change according to user submitted data. This is usually something conceptually shaky enough that I would not even attempt it, but I don't see myself having much of a choice this time. What I need to do then is to escape the HTML id to make sure it won't allow for XSS or breaking HTML.
Here's the code:
var user_id = escape(id)
var txt = '<div class="chut">'+
'<div class="log" id="chut_'+user_id+'"></div>'+
'<textarea id="chut_'+user_id+'_msg"></textarea>'+
'<label for="chut_'+user_id+'_to">To:</label>'+
'<input type="text" id="chut_'+user_id+'_to" value='+user_id+' readonly="readonly" />'+
'<input type="submit" id="chut_'+user_id+'_send" value="Message"/>'+
'</div>';
What would be the best way to escape id to avoid any kind of problem mentioned above? As you can see, right now I'm using the built-in escape() function, but I'm not sure of how good this is supposed to be compared to other alternatives. I'm mostly used to sanitizing input before it goes in a text node, not an id itself.