I have to write a program to verify text field in HTML forms.
So,I hane to verify a text field with lenth 10 & maxlenth 10.The
entered text should be as follows.
xxxxxxxxxy
where xxxxxxxxx denotes a combination of numbers and y should be one
of 'X','x','V'or 'v'.Also inputs such as 000000000v,0000 00000X are not
possible. 8 1826
In article <6d************ **************@ posting.google. com>, dm***@mail.com
(gunawardana) writes: I have to write a program to verify text field in HTML forms. So,I hane to verify a text field with lenth 10 & maxlenth 10.The entered text should be as follows. xxxxxxxxxy where xxxxxxxxx denotes a combination of numbers and y should be one of 'X','x','V'or 'v'.Also inputs such as 000000000v,0000 00000X are not possible.
Try reading your schoolbook and doing your own homework?
--
Randy
Hello,
Validate the string as:
str="012345678x ";
var pat = new RegExp(/[0-9]{9}[xv]/i);
if (pat.exec(str)= =null)
alert('Invalid input!');
--
Elias
"gunawardan a" <dm***@mail.com > wrote in message
news:6d******** *************** ***@posting.goo gle.com... I have to write a program to verify text field in HTML forms. So,I hane to verify a text field with lenth 10 & maxlenth 10.The entered text should be as follows. xxxxxxxxxy where xxxxxxxxx denotes a combination of numbers and y should be one of 'X','x','V'or 'v'.Also inputs such as 000000000v,0000 00000X are not possible.
"gunawardan a" <dm***@mail.com > wrote in message
news:6d******** *************** ***@posting.goo gle.com... I have to write a program to verify text field in HTML forms. So,I hane to verify a text field with lenth 10 & maxlenth 10.The entered text should be as follows. xxxxxxxxxy where xxxxxxxxx denotes a combination of numbers and y should be one of 'X','x','V'or 'v'.Also inputs such as 000000000v,0000 00000X are not possible.
I'm sure there's a Regular expression that does what you want with less
coding but here's one solution; watch for word-wrap.
<html>
<head>
<title>gunaward ana.htm</title>
<script language="javas cript" type="text/javascript">
<!--
function check() {
var form = document.forms[0];
var data = form.Data.value ;
if (data.length != 10) return;
if (data.substr(0, 9) == "000000000" ) return;
for (var i=0; i<9; i++) {
if (data.charAt(i) < "0" || data.charAt(i) > "9") return;
}
if ("XxVv".indexOf (data.charAt(9) ) < 0) return;
alert("OK!");
}
//-->
</script>
</head>
<body>
<form>
<input type="text" name="Data" size="10" maxlength="10">
<input type="button" value="Check" onclick="check( )">
</form>
</body>
</html>
JRS: In article <6d************ **************@ posting.google. com>, seen
in news:comp.lang. javascript, gunawardana <dm***@mail.com > posted at
Mon, 22 Dec 2003 20:32:27 :- I have to write a program to verify text field in HTML forms. So,I hane to verify a text field with lenth 10 & maxlenth 10.The entered text should be as follows. xxxxxxxxxy where xxxxxxxxx denotes a combination of numbers and y should be one of 'X','x','V'or 'v'.Also inputs such as 000000000v,0000 00000X are not possible.
But what do you mean by "such as"? With leading zero? With all zeroes?
There is an "or" facility in a RegExp, but not AFAIK an equivalent
"and".
Don't use a RegExp; use two, the second to deal with whatever "such as"
means.
OK = /^\d{9}(v|x)$/i.test(S) && /[1-9]/.test(S) // not 000000000
OK = /^\[1-9]d{8}(v|x)$/i.test(S) // not leading zero
See in <URL:http://www.merlyn.demo n.co.uk/js-valid.htm>.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr John Stockton <sp**@merlyn.de mon.co.uk> writes: There is an "or" facility in a RegExp, but not AFAIK an equivalent "and".
Not directly. There could be, since there is nothing in the technology
used that prohibits and "and" (and regular languages are closed under
intersection).
The closest you get is positive lookahead, i.e., to match five digits
and at least one 4, you can write
/^(?=\d{5})\d*4\ d*$/
Don't use a RegExp; use two,
Agreed. Often, a very complex regular expressin can be written as
two simple ones.
Example: String contains n "a"'s and m "b"'s:
Two regexps:
/^[^a]*(a[^a]*){n}$/
/^[^b]*(b[^b]*){m}$/
I won't even begin to write a regexp for n and m with values much over 2.
Try :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote in
news:1x******** **@hotpop.com: Dr John Stockton <sp**@merlyn.de mon.co.uk> writes:
There is an "or" facility in a RegExp, but not AFAIK an equivalent "and".
Not directly. There could be, since there is nothing in the technology used that prohibits and "and" (and regular languages are closed under intersection). The closest you get is positive lookahead, i.e., to match five digits and at least one 4, you can write /^(?=\d{5})\d*4\ d*$/
Actually you can use positive lookahead to implement an arbitrary "and":
/^(?=.*this)(?=. *that)/ (a trick introduced in the _Perl Cookbook_ and
implemented in a Perl module of mine).
However, doing two separate tests will usually be more efficient and the
lookahead trick should probably be used only when the match parameters
aren't known until runtime.
Eric Bohlman <eb******@earth link.net> writes: Actually you can use positive lookahead to implement an arbitrary "and": /^(?=.*this)(?=. *that)/ (a trick introduced in the _Perl Cookbook_ and implemented in a Perl module of mine).
The problem is that you can only do this efficiently at the end of a string.
Compare this for "or':
/z(aa|bbb)cd/
If we had the hypothetical & operator, and wrote
/z(.*this.*&.*th at.*)cd/
then we wanted the part between "z" and "cd" to contain both "this"
and "that".
If you do that with lookahead, you need to be able to bound the search
somehow, or the lookahead can test past the cd. As your example:
/z(?=.*this)(.*t hat.*)cd/
would incorrectly match
"z that cd this"
You need to ensure that the lookahead is only tested against the same
string as the other argument to "and".
You can do "the trick" and duplicate the continuation:
/z(?=.*this.*cd) (.*that.*cd)/
but even that can be broken by using more complex expressions. Take
"all digits, and at least three 4's":
/z(\d*&(.*4){3}. *)cd/
Doing the trick here gives
/z(?=\d*cd)(.*4) {3}.*cd/
However, that also matches
"z111cd444c d"
Again, you have to build your RegExps so the lookahead is bounded,
something that was not necessary with the hypothetical "&" operator.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
lallous wrote: str="012345678x "; var pat = new RegExp(/[0-9]{9}[xv]/i);
No. Either
var pat = /\d{9}[xv]/i;
or
var pat = new RegExp("\\d{9}[xv]", "i");
if (pat.exec(str)= =null)
if (! pat.test(str))
alert('Invalid input!');
[Top post]
Please do not do this, you are wasting
scarce and thus precious resources.
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Porcelli |
last post by:
I have the following code(excerpt) which grabs some lines from a
syslog
file and adds any found in the range to an array.
@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
|
by: Will |
last post by:
(My 4 questins at end after explination) The code below was provided to me
to "Popup" a window explaining what a Credit Card Verification Number is and
where to find it on a card... it is used as people enter their credit card
info on an ecommerce site. This is the first such site (Shopping Cart) I
have done and this code was provded by a user of the standard ASP Shopping
Cart software (CandyPress shopping cart.)
It works, but I don't...
|
by: Will |
last post by:
(My 4 questins at end after explination) The code below was provided to me
to "Popup" a window explaining what a Credit Card Verification Number is and
where to find it on a card... it is used as people enter their credit card
info on an ecommerce site. This is the first such site (Shopping Cart) I
have done and this code was provded by a user of the standard ASP Shopping
Cart software (CandyPress shopping cart.)
It works, but I don't...
|
by: Mike the Canadian |
last post by:
I am having a strange problem with field verification in a form. The
JavaScript below works just fine in Firefox but in IE. "license" is a
pull-down list and "requiredDiscount" is a text field. When license is
"Freeware" and requiredDiscount is "N/A", in IE (but not Firefox) you
get the message "For trialware you must enter a valid discount". It
seems that in IE "this", the form, is not set. I also tried using
"document.form" instead of...
|
by: Vladislav Moltchanov |
last post by:
I try to use MS Access application as data entry/verification tool in a
multi-centre international project, where each centre uses this
application for local project management and data collection. Regularly
the data are being unloaded , confidential information is masked, and
modified data are being sent to me for pooling and analysis.
One serious problem has emmerged recently: there are some centres where
local format for dates is...
| |
by: moi |
last post by:
Hello,
I try to make a login.aspx page to login an Active directory's user and i have a 1315 Web event Error in Windows server 2003 application's log with this error : 4006 Membership credentiel verification failed.
Could you help me ?
here's my web.config :
<connectionStrings>
<add name="ADConnectionString" connectionString=LDAP://server.domain.com/CN=Users,DC=domain,DC=com />
|
by: Vikas Kumar |
last post by:
propertyDescription += "<br>" + lblpropertyDescription.Text; //here
i am reading some text from text area
i test wrting "p" in my text area it wrks fine but when i write
<pin my text area it gives the following error
Error Message:A potentially dangerous Request.Form value was detected from
the client (lblpropertyDescription="
"). Stack Trace: at System.Web.HttpRequest.ValidateString(String s, String
|
by: mcmahonb |
last post by:
Hey people...
I've been searching this forum for a few hours and even though this topic has been went over from many different angles; I cannot seem to figure out how to make things work on my side.
I am trying to learn how to manipulate Dynamic Queries by forms via the example database: QrySampl.MDB, offered by Microsoft (as a learning tool, I suppose.) In particular, I am working with code from the example: "Query By Form (QBF) Using...
|
by: Jano |
last post by:
Hi - Happy New Year!
I have a web-site which accepted paypal payment for membership. No-one's buying so I want to make it free. The page which inputs the member details into the database needs verification, and I want to bypass the verification, but I can't figure it out. Can anyone help. - I have pasted the script below.
Many thanks,
Jano
<? include("header.php"); ?>
<?
// read the post from PayPal system and add 'cmd'
$req =...
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |