Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Validation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedValidation

 Post Reply Post Reply
Author
karp13 View Drop Down
Groupie
Groupie
Avatar

Joined: 03 January 2002
Location: United States
Status: Offline
Points: 152
Direct Link To This Post Topic: Validation
    Posted: 20 May 2003 at 7:58am

I need to validate that the contents of a form text field start with DTP.  This field will be for serial numbers that all start with these 3 letters.  Also this field is not required.  It only needs to be validated if something is entered in it.

How would I do this?

Thank you in advance!

Karp13



Edited by karp13
Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Direct Link To This Post Posted: 20 May 2003 at 10:57am

Try this:

<html>
<head>
<script name=javascript>
function checkInput(inputText)
{
var error

error = "ok";

//use the following line if the input isnt case sensitive
//inputText = inputText.toUpperCase();

if (inputText.length > 0)
{
 if (inputText.substr(0,3) != "DTP")
 {
  error = "There was an error.";
 }
}

alert(error);

}
</script>
<title>Untitled Document</title>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
  <input type="text" name="textfield" onBlur="checkInput(this.value)">
</form>
</body>
</html>

Back to Top
karp13 View Drop Down
Groupie
Groupie
Avatar

Joined: 03 January 2002
Location: United States
Status: Offline
Points: 152
Direct Link To This Post Posted: 20 May 2003 at 12:25pm

Perfect!!

Thanks

Back to Top
abhinav View Drop Down
Groupie
Groupie


Joined: 13 May 2003
Location: India
Status: Offline
Points: 63
Direct Link To This Post Posted: 19 June 2003 at 6:39am
I am a javascript learner .. thx for that script from me too =)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.