473,595 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to restrict user not to post more character

123 New Member
i have a text box i mean textarea(<texta rea></textarea>)
in my page i want to restrict user no to post more than
40 character how can i do that
Oct 9 '09 #1
4 2260
Dormilich
8,658 Recognized Expert Moderator Expert
for 40 characters, it’s probably easier to use a text input field (use the maxlength attribute).
Oct 9 '09 #2
TheServant
1,168 Recognized Expert Top Contributor
What Dorm said, for step one. Text Area is really for larger lengths of text, while Text is for smaller (<255 ~my very flexible rule).

This can be bypassed by some less honourable people, so you should have server side checking as well. When you are processing the form, be sure to include a check using strlen().

Expand|Select|Wrap|Line Numbers
  1. if (strlen($_POST['myvar']) > 40) {
    echo "myvar too long, please keep it under 40 characters."; return;
    }
  2.  
Or something like that.
Oct 11 '09 #3
zorgi
431 Recognized Expert Contributor
Hm...
If it has to be done I would probably opt for the solution in javascript rather than php.

http://www2.psacake.com:81/web/js.asp
Oct 12 '09 #4
TheServant
1,168 Recognized Expert Top Contributor
@zorgi
Agreed, but if it is important (maybe it's not) javascript can also be bypassed with ease, so PHP should be used if any databases are involved and/or it's important to have restrictions on user input.

Never trust anyone. Forms should always be thoroughly checked for nasty code that people put in. Form submissions can be faked and javascript can be turned off. Thankfully, PHP is out of the users reach so should ultimately have the serious checks in.
Oct 12 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2091
by: tracy | last post by:
hi, I have a table name stud_info where we stored student's information. This is a sharing screen for Undergraduate department and Post graduate department. To differential a student type either in Undergraduate or Post graduate is using programme type; 1 is for Undergraduate and 2 for Post graduate ; Now, i want to restrict example, Undergraduate department to view,
3
2492
by: vijay21 | last post by:
hi all, Can we restrict the number of characters that the user can input in a javascript prompt? my browser hangs whenever i try to input more than 2048 characters in it. Thanks for any help
3
2484
by: Agnes | last post by:
In textbox, I know I can set e.handled = false in keypressevent , So I can restrict the user to input some invalid character or disallow the user to input any thing Now, in datagrid, there are 3 columns one is account code, 2nd is debit, 3rd is credit for some account code, (e.g bank) I want to allow the user to input both debit and credit column/ BUT for some account code( E.g salary) I want to disallow the user type anything in...
10
8883
by: sconeek | last post by:
hi all, i have a textfield where i would like the user to input only Y or N. can somebody tell me how can i restrict the user from entering any other character, number or special character. thanks.
12
2487
by: Me | last post by:
I'm trying to wrap my head around the wording but from what I think the standard says: 1. it's impossible to swap a restrict pointer with another pointer, i.e. int a = 1, b = 2; int * restrict ap = &a; int * restrict bp = &b;
21
6492
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no definition found in K&R 2nd.
2
2204
by: den 2005 | last post by:
Hi everybody, How do restrict entering these characters <>\"%';()& and telling user these caharcters are not allowed to be enter in the textbox field using RegularExpression Validator? I put in the Validation Expression property . It restrict every character execpt 0 to 9. How to fixed this? I used + in validation Expression property of Regular Expression Validator Control. All are working except when entering the character \, which...
5
8212
by: Dakrat | last post by:
Allow me to preface this post by saying that this is my first database project, and while I have learned a lot, any concepts I have learned are hit and miss as I have found new requirements and researched solutions. That said, I have a "training" database with PowerPoint briefings which I have users access and complete training. The form then records the date and time they completed training in a relevant field. I have a separate "master"...
4
1584
by: cyberlei | last post by:
like user have to type "A" for the first character in the blank bar,so how can i restrict the "A" for the first character in php string? Thank you
0
8379
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
8019
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
8251
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
6674
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 project—planning, coding, testing, and deployment—without 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
5839
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
5418
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();...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1223
bsmnconsultancy
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...

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.