Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Checking number of characters entered in form field

Posted on 2003-03-10
2
Medium Priority
?
191 Views
Last Modified: 2010-03-05
So I have this form where a user simply enters an 8 character accesscode... All I want to do is, after the user presses submit, print an error message if the user did not enter exactly 8 characters.  How would I do this in perl?  Thanks!

DiamonDogX
0
Comment
Question by:DiamonDogX
2 Comments
 

Accepted Solution

by:
sykkn earned 100 total points
ID: 8107429
Use the length() function.

============================================================
print "ERROR!" if(length($myVar) != 8);
============================================================
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8112731
Use javascript in the htlm

<head>

<script language="JavaScript">
function formSub() {
 if (theForm.accessCode.length != 8)
    alert("enter 8 characters");
 else
    theForm.submit();
}
</script>

</head>

..... your form with no submit buttom ....
A submit link
<a href="formSub()">Submit</a>

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

569 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