Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Limit Textbox Entry

Posted on 2003-11-04
2
Medium Priority
?
604 Views
Last Modified: 2012-05-05
I want to limit the text entered into my textbox in the following ways:

If name="Jed" Then
  maxLength="6"
ElseIf name="Ted" Then
  maxLength="5"
Else maxLeength="4"

Also, you can only enter the following characters:
FLAfla1234567890

Also, you can only enter the following combo of letters:
either    FL
or    A

You may only enter one A or you may enter FL or you can enter no letters but numbers only!
0
Comment
Question by:yourbudweiser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Expert Comment

by:superslamwich
ID: 9683206
Heres for the entry, I'll get a maxlength script for you in a sec:

<script type='text/javascript'>
<!--

function validate(obj)  {
  val=obj.value
  re1=/(F)/i
  re2=/(L)/i
  re3=/(A)/i
  re4=/(\d+)/
  re5=/[^FLA0-9]/i
  q=0
  if(re1.test(val))  q=q+.5
  if(re2.test(val))  q=q+.5
  if(re3.test(val))  q++
  if(re4.test(val))  q++
  if(re5.test(val))  q=q+2
  if(q==1)  {
    alert("OK")
    return true;
  } else {
    alert("NOT OK")
    return false;
  }
}
//-->
</script>

<form onSubmit='validate(this.form.elements["joe"])'>
<input type='text' name='joe'><br />
<input type='submit value='CLICK'>
</form>
0
 
LVL 3

Accepted Solution

by:
superslamwich earned 300 total points
ID: 9683212
Whoops, make that this:

<script type='text/javascript'>
<!--

function validate(obj)  {
 val=obj.value
 re1=/(F)/i
 re2=/(L)/i
 re3=/(A)/i
 re4=/(\d+)/
 re5=/[^FLA0-9]/i
 q=0
 if(re1.test(val))  q=q+.5
 if(re2.test(val))  q=q+.5
 if(re3.test(val))  q++
 if(re4.test(val))  q++
 if(re5.test(val))  q=q+2
 if(q==1)  {
   alert("OK")
   return true;
 } else {
   alert("NOT OK")
   return false;
 }
}
//-->
</script>

<form onSubmit='return validate(this.elements["joe"])'>
<input type='text' name='joe'><br />
<input type='submit' value='CLICK'>
</form>

{Slam}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question