JQuery :: Basic Regulaer Expressions Fails?
May 24, 2010I'm trying to replace a ^ if the user types it in. This works ..
[Code]...
I'm trying to replace a ^ if the user types it in. This works ..
[Code]...
i have a very simple ajax request, on Chrome and FF, IE 8 it works very well. IE 8 returns "error", "complete"
the content /test.php :
<div>test</div>
Ajax request:
$(document).ready(function()
{
$('#test').click(function(){
$.ajax({
[Code].....
I have a string content which include the content "[some number]". I wanted to replace the inner number which is inside the square bracket with jQuery regular expressions. the number inside the brackets are always variables.
View 3 Replies View RelatedI´ve problem with Validation plugin... I´ve one select like this..
[Code]...
Next problem is with the right phone number format.. I have a PHP regular expression, but I don´t know how to insert this regExp into JS.
I'm about to embark on really learning jQuery. The first step of which is to get a basic jquery function to work. Everytime I learn something this way the first thing does not work for no apparent reason. It's probably something obvious but I can't move on without getting this to work. I added jquery to the page I have two things a div called #content-container and an image with class .logo
[Code]....
My shopping cart is using jQuery UI 1.7.2
I added jQuery UI Datepicker 1.8.7
I'm including jquery.ui.datepicker.css and jquery.ui.all.css versions 1.8.7 in my header, when I click the input box firebug shows the datepicker code is in the source but the ui-helper-hidden-accessible class isn't being removed to display the datepicker. Do I need to update jquery or at least ui.core which is 1.7.2?
After playing with the css files I was able to get the datepicker to open but the prev and next text is being displayed above the prev/next buttons
I've tried every combination I could with these files to get a basic datepicker to open up
I've got the following code block in one of my pages ...
<?php
if ($config->theme->short_name == 'default')
{
?>
<script type="text/javascript">
[Code]...
Shouldn't the code above set the .html property of the element with class "error_box" to the specified text? I've tried using an id instead of a class i.e. $('#error_box").html(...) but that doesn't work either. I've also tried using the .text() method.
Manually using document.getElementById("error_box") works without any problems - it's only jQuery that won't do what I tell it. :-)
When i add this simple function. i am not able to fade the image back n forth.
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[code]....
I am using a JS form validator that uses the following regex to test whether a string contains at least one unsigned int and one letter.
var reAlphanumeric = /^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)([0-9a-zA-Z])+$/;
function checkAlphaNum( theField ) {
if ( isWhitespace( theField.value ) || !reAlphanumeric.test( theField.value ) ) {
return false;
} else {
return true;
}}
Since IE5 doesn't support look ahead expressions, I am using the following function to get the same result in IE5.
var reUnsignedInteger = /^[+]?[0-9]+$/;
var reAlphabetic = /^[a-zA-Z]+$/;
function IE_AlphaNum( s ) {
var isInt = false;
var isLet = false;
var isOp = false;
var len;
var setStr = strArray( s );
for ( var i = 0; i < setStr.length; i++ ) {
if ( reAlphabetic.test( setStr[i] ) ) {
isLet = true;
break;
}
}
for ( var i = 0; i < setStr.length; i++ ) {
if ( reUnsignedInteger.test( setStr[i] ) ) {
isInt = true;
break;
}
}
for ( var i = 0; i < setStr.length; i++ ) {
if ( !reAlphabetic.test( setStr[i] ) && !reUnsignedInteger.test( setStr[i] ) ) {
isOp = true;
break;
}
}
if ( isInt && isLet && !isOp )
return true;
else
return false;
}
Can a regex be used that will satisify the one int/one letter rule that will work in IE5 or if not, can the above function be refactored w/o having to interate through the string array each time? Neither method works in Opera 6. Also, is there any condition except for validating perhaps a password where such a rule would be needed?
check out the Social Media "more" button dropdown at:[URL]
It's supposed to grown in size, and then fade the icons up.
In IE, it grows but then does nothing.
The jQuery code:
<script type="text/javascript">
jQuery( function(){
$grown = 0;
jQuery("#more-social").click(function() {
[Code]....
Im trying to make a sticky footer and it works fine in all fo the browsers except ie, it wont add the needed height, when using height() it works but if i use innerHeight() it wont work, heres the code
[Code]...
jquery-1.4.2.min.js
I'm trying to use the Alt+keyCode in my web-app and want to prevent the event from bubbling up to the browser.
The following works fine in FF & Chrome, no event propagation, but fails in IE8:
$().ready(function() {
$('html').keydown(function(event) {
if (event.altKey) {
if (event.altKey && event.keyCode == 83) { // 'S'
[Code].....
Coding patterns for regular expressions is completely unintuitive, as far
as I can see. I have been trying to write script that produces an array
of attribute components within an HTML element.
Consider the example of the HTML element TABLE with the following
attributes producing sufficient complexity within the element:
<table id="machines" class="noborders inred"
style="margin:2em 4em;background-color:#ddd;">
Note that the HTML was created as a string in code, and thus there are NO
newlines ('
') in the string, as if a file was parsed...so newlines are
not an issue. The only whitespace is the space character ' ' itself,
required to delimit the element components.
I want to write an RE containing paranthesized substring matching that
neatly orders attribute components. The resulting array, after the
execution of the string .match() method upon the example, should look as
follows:
attrs = [ "id", "machines", "class", "noborders inred", "style",
"margin:2em 4em;background-color:#ddd;" ]
I can then march down the array (in steps of 2) setting attributes
(name=value) to the element using standard DOM interface methods, right?
In approaching the writing of the RE, I have to take into account the
characters permitted to form the attribute name and the attribute value.
I assume a start to the RE pattern as:
<attribute name>=<attribute value>
I then try to find the right RE pattern for <attribute name>, keeping in
mind what the legal characters are for attribute names according to the
HTML standard ("recommendation"):
[A-Za-z0-9-]+
I believe this patterns conforms to the standard for attribute values:
[,;'":!%A-Za-z0-9s.-]+
That pattern tries to be more exclusive than inclusive, although I think
just about every character on the planet, including a newline, is
acceptable in an attribute value, at least the kind one might see in an
HTML document. Code:
I am trying to construct a reg exp for a field which can accept username as
(username) or (username@domain.com/net/org etc).
username should allowed alphanumeric values also it should accept -,_,.
it should not allowed @ twice
I'm having a problem making the regular expression for U.S. zip code verification work.
the regular expression: /(^d{5}$)|(^d{5}-d{4}$)/
My code is below. No matter what I type in, it asks me to correct my zip code. Any suggestions? Code:
I am trying to use regular expressions within JavaScript for the picture upload component of a shopping cart. I still can't seem to get my mind around them.
I have a page with a working file upload. When you click on browse and then select your file, the file name is also returned to the second field, the picture name field. The problem is that the entire string is returned - 'G:CatalogMyPicturessomepic.jpg' instead of 'somepic.jpg'.
I know this can be pulled out with regular expressions, everything from the right until it hits a / or I included the script and a couple of links. Code:
I have a table of data, and I would like these options to show up when that <td> is hovered over, but as you can see this hides/shows every <td>.
$('div.msgEdit').hover(function() {
$('td .msgEdit a').show();
},
[code]....
How can I get rid of the slide effect on a basic horizontal menu? I love the way the "basic" example works but I can't mimic it without having the text all slide to right and re-sizing the box.
View 2 Replies View RelatedI am trying to create a basic a accordian style menu. Im guessing i have done 90% of the code, but a little stuck now.I have three widget and what I am attempting to do is hide all the widgets apart from the one actually clicked. My code so far is as follows.
$(".widget-title").click(
function () {
$("#widget1_content").hide(); //My Widgets
$("#widget2_content").hide();
[code]...
I have what I thought was a simple piece of code to count characters in a text area. The code works fine in FF and safari, but not in IE. Can someone explain if the problem is my code or something else.
View 3 Replies View RelatedI have been playing with a bit of code I found of the web and it works well, it basicly allows me to create pages and navigate between them all done via JQuery. The one question I have is, how hard is it to add some simple animation to it, such as fadein which if I have read correctly is built into JQuery?
code below:
know there is a similar post on here but it didn't really give me any actual help on this topic:It seems that I have the correct regular expressions in this however it doesn't want to follow my freaking instructions can you guys maybe show me where I'm going wrong and give me a short source code on how to rectify it. Code is below:
function validate(theForm)
{
var falseCounter = 0;
[code]....
I'm trying to validate the form, but each time I try to do so, all fields return invalid. I've tested my regular expressions with various online testers and they seem to work fine, am I perhaps using it in the wrong way? Or maybe a problem with my functions?
[Code]...
i'm trying to use a regular expression to verify an order. I basically don't want any decimals or negative numbers allowed. I believe I have any digit 0-9 one or more times and negating decimals. but for some reason it allows decimals and letters. also is it correct to put return true or can i just leave it blank?
var varifyThree = /^\d*[^\.]$/;
var productThree = document.getElementById('prod3').value;
if (productThree==null || productThree=="" || varifyThree.test(productThree)) {
return true;
[Code].....
I keep getting an error that says item is null. I'm a little lost because once I got my regExp to start working this actually worked for a little bit. When I came back I was getting an error.
var creditExp = /^([345])(\d{3})\-?(\d{4})\-?(\d{4})\-?(\d{4})$/;
var creditNumber = document.getElementById("creditnum").value;
var item = creditExp.exec(creditNumber);
document.getElementById("creditnum").value = item[1] + item[2] + "-" + item[3] + "-" + item[4] + "-" + item[5];
if (item[1] == 4 && document.getElementById("card1").checked == true) {
return true;
}else
if (item[1] == 5 && document.getElementById("card2").checked == true) {
return true;
}else
if (item[1] == 3 && document.getElementById("card3").checked == true) {
return true;
} else {
alert("You must enter a valid credit card number.");
document.getElementById("creditnum").focus();
return false;
}
var billingName = document.getElementById('creditname').value;
if (billingName == null || billingName == "") {
alert("You must enter your first name as printed on your credit card!");
document.getElementById('creditname').focus();
return false;
}
I'm doing a bit of experimentation and would like a bit of advice if possible please.
In my switch statement I would like to use the || or operator, it works correctly it I set the case to 31, but if I try 1||31 it doesn't.code...