473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Finding period/dot (.) in HTML form input using regular expressions

Greetings,
I am a novice in Javascript and I am not able to succeed finding right
regular expression for my requirement.

Input in HTML form should be in the format of row.rack.bin i.e
three separate words separated by two dots/periods. User can enter
"xyz.." also. Minimum two dots/periods must be present. Here is my
code, it works partially. Please point me to the right expression.

<script>

locatorfmt=/[^\.]\.[^\.]\.[^\.]/i;

function validateLocator() {
locator=document.getElementById('p_item_location') .value;
if (locator.search(locatorfmt)==-1) {
alert('Please enter locator in correct format');
return false;
}
return true;
}

</script>

thanks
Sudhakar
Jul 20 '05 #1
1 5193
In article <bd**************************@posting.google.com >,
i_***********@hotmail.com (Sudhakar Doddi) wrote:
Input in HTML form should be in the format of row.rack.bin i.e
three separate words separated by two dots/periods. User can enter
"xyz.." also. Minimum two dots/periods must be present. Here is my
code, it works partially. Please point me to the right expression.
There's a lot of ambiguity here. What characters
can be in a "word?" letters, numbers, punctuation other
than dot, spaces, tabs??? [^.] allows all those but
do you want that?

What does "minimum" mean? Is more OK?
locatorfmt=/[^\.]\.[^\.]\.[^\.]/i;
No need for the "i" since there are no letters in the pattern.

Dot doesn't need quoting inside [] -- [^.] is OK.

You need [^.]* to allow zero or more non-dots.

[^.] is "not dot" and [^.]* is zero or more not-dots, so

locatorfmt = /[^.]*\.[^.]*\.[^.]*/

if (locator.search(locatorfmt)==-1) {


search() looks everywhere. Do you really want to allow
something like "Hi -- my name is Bob -- what's yours? ..."

If you want locator to just have row.rack.bin, no
extra dots, no spaces, use something like this:

/^\S*\.\S*\.\S*/

For lots of other pattern options, see

http://www.visibone.com/regular-expressions/
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mosas | last post by:
Dear All In Perl when we are checking some conditions using regular expression we can ignore the case sensitive of a string using the following regular expression /(^)|/|(\.\.)/i. But If I try...
1
by: Daniel Walzenbach | last post by:
Hi, does anybody know I can extract a substring of a text with regular expressions. Let’s consider the following text: “Regular expressions are often used to make sure that a string matches a...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
8
by: Luke Matuszewski | last post by:
Hi ! I have faced the problem of checking that the user has entered the unicode letter (not only ASCII set of letters...). It seems that ECMAScript 3rd regular expressions do not include posix...
0
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
0
by: pramodjava | last post by:
HI , I am trying to validate an email in vb6.0 using regular expressions, how can i do this , Thnaks
2
by: Alpha83 | last post by:
Hi, Is it safe or error-free to validate country zip-codes using regular expressions - especially for countries like UK or Canada, where there are different alphanumeric formats. Here's what I...
1
by: blackirish | last post by:
Hi all, i am trying to write a program which takes a regular expression and generate data according to that expression. I know it's possible because there are such programs to manage this task. Do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.