473,698 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=documen t.getElementByI d('p_item_locat ion').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 5223
In article <bd************ **************@ posting.google. com>,
i_***********@h otmail.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
2040
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 to do this in Python I couldn't get any result. So Any body know regarding this Kindly mail me with example.
1
2051
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 certain pattern.”. I e.g. want to extract everything between “expressions” and “a” which is in the above example “are often used to make sure that”. The unfortunately best I could do was the following piece of code: Dim...
3
3213
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 that this will one or more occurrences to replace all the white space between with a comma. This search ElseIf InStr(1, indivline, "$") Then insert a replace statement that uses the regular expression to find and replace all the white space...
4
5177
by: Egyd 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 adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
8
1575
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 character classes like: \p{L} , which above stands for Unicode letter. Maybe someone has done it ?
0
1952
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 of string manipulation where they seek through the string back and forth doing replacements to substitute in the needed HTML code. I am convinced that this can be done with a few regular expressions. Unfortunately my knowledge of regular...
0
1273
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
3881
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 got for UK - System.Text.RegularExpressions.Regex(@"^(({1,2}{0,1}) \ ({2}))|(GIR\ 0AA)$"). Got this from regex.lib, and needed to know also if there are better approaches for zip code validation.
1
1730
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 you know how to generate data using regular expressions in C# ? Thanks in advance
0
8671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8856
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.