Regex/replace White List
Feb 17, 2006What is the best way to white list a set of allowable characters using
regex or replace? I understand it is safer to whitelist than to
blacklist, but am not sure how to go about it.
What is the best way to white list a set of allowable characters using
regex or replace? I understand it is safer to whitelist than to
blacklist, but am not sure how to go about it.
I have a little Ajax script and I'm trying to remove some CSS elements from a DIV tag and I'm have a bit of trouble with the Regex. Right now I'm trying to remove the z-index attribute. It can look something like any of these:
z-index: 1000;
z-index: 0;
z-index: 75;
etc...
Here's what I'm using right now:
document.getElementById('right_column').innerHTML.replace(/z-index: [0-9]; /gi, "replaced"));
It replaces z-index: 0; just fine but I can't find the correct modifiers to make it work for 2, 3 or 4 digit z-indexes.
Working with TinyMCE to enable editor to toggle off html mode, what I'm struggling with is converting list items into asterisks [code]...
View 4 Replies View RelatedRight now when someone clicks on my listbox I immediately do an update on the form to populate the selected item.
Is there a way to detect if a user has clicked on some white area of a list box? If my list is sized 8 items but the list only has 4 items, if the user clicks near the bottom of the list where there is no item to select, can I detect that? Currently I get the form updating even if I click on the white area of the list and I'd like the form to update only if I actually click on an item in the list.
I am writing a script that will replace the src of an image when the user hovers over it. I am using jquery and regex to accomplish this and have tested it on my local server but the src of the images on the live server is different and uses a non-relative path.
Here is my code
$(document).ready(function() {
$("img.imagefield").mouseover(function() {
var regex = "^(http|https|ftp)://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/sites/all/files/[a-zA-Z]*";
var src = $(this).attr("src").match(regex) + "_silly";
[Code]...
I have a form where I ask my users for a comma seperated web site list. I want to make sure this list only contains the host names of URLs without any white spaces
Original list: [url], [url], [url],[url]
Edited list:[url],[url],[url],[url]
Currently I have the following to get the comma separated list
Code:
var list = document.getElementById( "list" ).value ;
Is there a way to make one regex to replace a space with " " and a tab with " "?
Currently I'm using two regex's with string.replace( ... ).replace( ... ), but that means it has to run through the string twice. Any way to do what I want in one regex?
I've been told that jQuery can do this.
Simple form which includes a drop down list of users obtained from a database which is displayed using a form select entry with options for each entry. problem is, the list can be quite long, upwards of several hundred.
In PHP, I added a filter box (text box) which the visitor can enter in a substring that is then used to obtain and display only matching entries. Works great, but it needs to reload the page to do its thing.
I've been told that jQuery can be used to do the same thing without having to reload the whole page.
The filter box would be used to call an existing PHP script which obtains the names based on the filtered string. I can change this script to output the data in any format necessary including raw format to full option formatted strings.
how to set this up so that it gets called and replaces the current option content.
Attachments
select01.png
Size : 2.99 KB
Download : 272
I am creating a class for all of my code snippets, using a formatted paragraph (and "word-wrap: pre") to keep formayting intact. The problem is that in keeping my HTML files formatted nicely, they are indented, and due to the "pre" formatting the indentation is kept. Code:
View 2 Replies View RelatedWhy this code doesn't work? All I want to do is removing all the white spaces.
JavaScript
function validateForm(){
var postcode1 = (document.form1.textPostcode1.value).replace(/^s*|s*$/g, "");
if (postcode1 == "") {
[Code].....
I've about 50`000 jpg images on a dir. Some images have a white frame, other
only 2 white lines, sometimes vertically, sometimes horizontally.
I've to show those image on a darkgrey background, and the result is ugly.
It's there any way to detect those white lines, then change their color for
showing on the screen ? I won't change the color of the frame on the image
itself, but when showing them. Also take in mind that some parts of the image are white, and they must be kept white!
A website I've been working on has a black bar across the bottom. Under some conditions, however, there is a gap between the bar and the bottom of the page -- white for the body. The conditions vary between browsers and OSes. To keep things simple, I'll describe what happens with my principle development environment -- Chrome under Ubuntu.
The main body of the website is fixed width, centered against a neutral background. If the browser window is narrowed so that a horizontal scrollbar appears, the gap appears.
I have tried various things to find the gap so I can move the bar down or whatever but nothing seems to work. I tried using the document height but I found that it is greater than the actual display area which probably means that it is including something not visible (which is fine) but how do I reliably determine the extra? Or is there another solution I should be looking at (I won't bother listing all that I have tried)?
i m using the following validation code to validate email id
if (!/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,4})+$/.test(document.getElementById("customer_name").value))
{
msg=msg+"Must Enter a valid Login-id/Email
";
document.getElementById("customer_name").focus();
}
now i need that if the email id contains white blank space in front of email id or end of email id then this validation should pass otherwise not.
at present if there is blank space in front and end of email id then the validation doesnt passes and gives alert.
what should i add in it to validate it or how can it automatically remove white spaces before validating.
How can I to delete white spaces around parameter that I to pass with HTML forms.
For example, if I have 'firstname lastname ' or ' firstname lastname', exist it a builtin function in javascript to obtian 'firstname lastname'?
I have a string variable:
var mystring = ' hello world ';
How can I truncate white spaces placed before or after my string value?
I have a frame that includes a hidden <div> at first (before any action), the problem is that when opening the page, I have a white space, and i can't reduce the size of the frame because the content of the <div> will not appear!
how to hide the white space of the frame without reducing it's size?
how do I finish this so it removes all white-space charcters, not just the first.
(xarray[i].replace(/s+/,'')
Here's what I'm trying to do: I need a div to pop-up below a list item with more information (that will basically describe the list item in detail). I also need the div code to be included on the same page- not called from a separate php file.
I've cut out the bulky content and included the styles attached to the elements in the code below (instead of leaving the classes I'm using).
Code:
<ul>
<li><a href="javascript:document.getElementById('1').style.display='inline'">First List Item</a> <br />
[Code].....
This works fantastic in Safari... but for some reason, not in firefox. (these are the only two I've tested). In Firefox, clicking the links opens a blank white page with the sinlge word inline.
Or a more efficient way of accomplishing this task (without a mess of attached .js files),
I've created a page with an image of a man where a user is able to click on an area and a div is positioned at that point containing a white circle. This code works in all browsers except IE 6 where it creates a duplicate white circle beneath the one which is placed in the correct location. How to get rid of this second circle? The circle is essentially a div with a background image assigned.
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ImageClick.aspx.vb" Inherits="ImageClick" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]" >
<head runat="server">
<title>Image Click</title>
<script type="text/javascript" language="javascript" src="JQuery.js"></script>
<script language="javascript" type="text/javascript">
window.onload = Init .....
Might someone know the keyword to add additional white space underneath li tags (in a ul context)?
View 4 Replies View RelatedWhen addClass('choose') to li, there is always a white space right under it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URl]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" src="demo_inc/jQuery.js"></script> .....
I have a div called "sampler".
This is the CSS code of this div[code]...
In slideshow running on xp_pro/ie8, after the last slide is displayed, a small white rectangle (approx w:60px h:20px) at the top left positionwhere the1st slide is about to re-appear. The 1st slide then displays correctly, as doall the slides, but I can't keep the rectangle from showing up.
[Code]...
I'm having trouble getting FireFox 2 to play nicely with a jQuery fade. Here's a paired-down example:[URL]..I've made the source code VERY basic here to make it clear what's what. When you click the link, some jQuery fades the image in and out. But it also makes all the text go thinner. Clicking away from the link then sets the text back to how it was.
Any ideas why this could be? I've googled it and although I can find people with issues around jQuery's fades, I can't seem to find a solution to this one.
I'm thinking of putting a pop-up on one of my sites using the following javascript. I only want it to pop-up when a visitor visits every 25 days or so. Can someone tell me where I put the code for that in the below script or point to a script where this is already done? Code:
View 3 Replies View RelatedI am having problems with a template I bought. When I customize the menu, and the items have many sub items. the white background slides down way too much. I am learning jquery and can´t find where to correct this URL...See the items: "Diplomados" "Servicios a alumnos" and "convenios".
View 2 Replies View Related