DHTML Form Validation - Regular Expression
Jul 11, 2005
I have purchased the new DHTML Utopia book and I am trying to implement the form validation method that they use in the book, everything is working fine except for my knowledge of regular expressions .
The book uses the example of ^[- ()0-9]+$ to ensure that only numbers are added to a particular form field.
I know this seems like a trivial question but I have googled and not been able to find an answer.
What is a REGEXP that will ensure that I do not get an empty field. That is I want to make a particular field required.
I really like how easy the script is to implement (once I got my head around it) but I'm just struggling with Regular Expressions.
View 2 Replies
ADVERTISEMENT
Aug 7, 2009
I would like to validate a textbox that numbers cannot be entered into the text input, how do i do this??? With regular expression??
View 8 Replies
View Related
Jun 23, 2005
I have got some problem when i check email through javascript. Currently, i have used this script:
/^[^@]+@[^@]+.[a-z]{2,}$/i
but through this expression it is unable to find that after "@" and before "." there's any string or not.
View 1 Replies
View Related
May 6, 2011
Working on a validation API and having trouble with a PO BOX validation Regular expression. I tried adding ? and ?! in front of the regular expression but I want the exact opposite of what is doing. I want any entry besides combination's of po box entries to be allowed.
View 3 Replies
View Related
Feb 23, 2010
I am trying for validation using regular expression for Indian mobile number. Simply i have tried for"^[8,9]{1}[0-9]{9}$" and some others also but it is not working. I want regular expression for: 10 digit mobile number starts with 8 or 9
View 2 Replies
View Related
May 3, 2010
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]...
View 4 Replies
View Related
Feb 21, 2006
I have seen lot of reg. expession with ?:
For dummy eg
(((XXX)ddd)ff)
The above expression is modified as
(?:(?:(XXX)ddd)ff)
Although both the above expr. gives same result. (RegExp.match() gives
same o/p), most of the places , i have seen second option.
Yes, but different matches r shown (using RegExp.exec())
Is the second expr. most efficient or in particular scenarios?
Any comments???
View 5 Replies
View Related
Jun 28, 2006
At the moment my code is like:
function telValid(inString) {
var regexp = /^[0-9 +()]+$/;
return (inString.match(regexp,''));
}
which is use to validate phone numbers (UK at the moment)
this works ok, but wont allow - (Dashes) which i need..
tried doing:
function telValid(inString) {
var regexp = /^[0-9 +-()]+$/;
return (inString.match(regexp,''));
}
View 2 Replies
View Related
Jan 20, 2007
I am finding it difficult to find a regular expression for following situation(replace)
a b c d = a,b,c d
a b c = a,b c
View 8 Replies
View Related
Feb 5, 2009
regular express to get the file name from a URL?
It has to be flexible in that the extension can be either 4, 5, or 6 chars (.php, .html, .shtml for example) and needs to cater for and whether querystring parameters exist too.
So, both
[URL]
and
[URL]
The regex should return newthread for both.
View 4 Replies
View Related
Nov 13, 2009
I.E.:
---------------------------
Windows Internet Explorer
---------------------------
<EMBED src=http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1& width=500 height=200 type=application/x-shockwave-flash allowfullscreen="true" allowscriptaccess="always"></EMBED>
how can i get "src" value in above code using regular expression?
<object width="500" height="200"><param name="movie" value="http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1&"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="200"></object>
how can i get "src" value in above code using regular expression?
View 6 Replies
View Related
Jul 7, 2010
what will be the regular expression for this line:
Code JavaScript:
var id = $(this).attr("href").substring( $(this).attr("href").lastIndexOf('#'), $(this).attr("href").length);
Basically it gets the string after # in href attribute of clicked anchor tag.
View 3 Replies
View Related
Aug 26, 2010
I have this expression:
/(19|20)dd/)[- /.](0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])
to detect if my date:
2010-12-15
is valid. It's not working. What do I have wrong?
View 6 Replies
View Related
Dec 30, 2004
When Internet Explorer 5.01 for Windows hits the regular expression:
/(?=<)|>/
it complains about an unexpected quantifier. In fact, it seems to complain whenever I use a lookahead expression. Is there any way around this?
View 2 Replies
View Related
Jul 23, 2005
does anyone know how I can build a regular expression e.g. for the
string.search() function on runtime, depending on the content of
variables? Should be something like this:
var strkey = "something";
var str = "Somethin like this";
if( str.search( / + strkey + / ) > -1 )
{
...
}
View 9 Replies
View Related
Dec 7, 2006
I need a regular expression that will validate a double quote comma
delimited list where the odd entries are numeric and the even are
alphabetical. Each pair must also be on a separate line. For example:
"1","Peter"
"2","Paul"
"3","Mary"
I've used the following expression to validate comma delimited lists, but
without the double quotes, numeric/alpha pairing and line return
restriction.
^([A-Za-z0-9]?)+([,]s?([A-Za-z0-9]?)+)*$
View 1 Replies
View Related
Oct 9, 2007
Normally I can write regular expressions decently well but for some
reason I am having trouble getting this to work. I am validating form
data and need to throw an error if there are ANY spaces in the field.
abc123 is fine, abc 123 is not. Any character is fine, just not a
space.
View 2 Replies
View Related
Jul 20, 2005
All I'm trying to do is delete the lines which don't contain a particular
string. Actually a filter to edit a log file. I can find and replace a thing
with null, but can't figure out how to find the lines which do not contain
the thing.
Going further, I want to generalize and use a JavaScript variable containing
the decision string, but first I need to worry about the not-within-a-line
problem.
View 26 Replies
View Related
Oct 15, 2010
Does jQuery support a regular expression as a selector? eg: so I can get every element with a id beginning with "test"
View 2 Replies
View Related
Mar 19, 2008
I've got a somewhat cumbersome function that looks like this.
Code:
parseCSVLine = function (line)
{
var tmp = [];
var inQuote = false;
[Code]....
View 4 Replies
View Related
Apr 30, 2009
Here is the form in question: spraytechDOTcom/download_form.asp I am so close to getting this to work the way that I want, but here is what I am having an issue with: I cannot seem to make it look for the 12 digits that are in the phone numbers that we are going to collect. Ex. 800-123-4567
It doesn't have require 12 characters if there is another way to get the number to validate looking like the example above. Here is my regular expression that I am struggling with:
var re = /[^d-]$/ It seems to block any letters, but it will accept only 1 number. I would really like it to make sure that the phone number is only entered like this: 800-123-4567.
I have looked for days trying to figure this out and have only gotten close.
View 7 Replies
View Related
Mar 31, 2009
I'm trying to validate data in a textbox for township (usually written as 12N or 23S for Township 12 North or Township 23 South). In Utah the townships range from 01N to 15N, and 01S to 44S. The expression "/[0-9][0-4][ns]/i" will allow 01n (or s) through 94n (or s). If I change it to "/[0-4][0-4][ns]/i" to limit it to 44n (or s), I then am not allowing for 05, 06, 07, 08, and 09. I hope the above is not too confusing. I'm just starting to work with regular expressions.
View 2 Replies
View Related
Sep 8, 2009
I would like to perform a regular expression on a string and if TRUE do something.
I have huge amounts of knowledge doing this in PHP but trying out javascript.
View 1 Replies
View Related
Jan 27, 2010
This is my first serious attempt at using a regular expression.My first name field should allow alpha characters only [A-Za-z], but it seems to be testing for the presence of 1 alpha character. If one is found in the string then anything else is allowed.Bob returns valid which is what I need.Bob1 returns valid but should NOT be valid..1 returns valid not valid which is what I need.My code.
function isValidFirstName(p1_firstName) {
//http://www.javascriptkit.com/jsref/regexp.shtml
var re = new RegExp("[A-Za-z]");
[code]....
View 6 Replies
View Related
Feb 4, 2010
I am creating a regular expression for a URL where the domain name (i.e. .com|.edu etc) is optional. That is both http://xyz and http://xyz.com should be valid. If <.> is present then com|edu|.. will be there; but if <.> is absent then com|edu|.. will not be there. Also there can be any number of <.>, but every <.> will be followed by characters. So in other words the string can't end with <.>, it should only end with [a-zA-Z0-9]. So far I have created the following part -
var url=document.myform.addr.value;
var str="^(http|https)://(([a-zA-Z0-9.-]+)*[a-zA-Z0-9-]+.(com|edu|gov|[a-zA-Z]{2})|[a-zA-Z0-9]+$)";
var regEx = new RegExp(str);
[Code]....
View 9 Replies
View Related
Jun 4, 2011
I have the following string "d3-23-76-546"
I'm looking for a regular expression that will match everything in this string before 546 so that I can replace it with an empty string and just be left with 546. The string could be of any length and contain any number of hyphens.
View 2 Replies
View Related