Jump to content

Javascript to limit the text field input


Recommended Posts

Hello everybody,

I have a field in the datapage that accepts upto 2 characters. i want to limit the input entered to <=25. Any idea how do i do that. I know i have to write some kinda javascript.

Here's the datapage:

http://b2.caspio.com/dp.asp?AppKey=72721000i7b3a2a7d3j2i5h9h1j9

Field name is Total no. of students taught each day:

the user input should not exceed 25.

Please help.. :(

Link to comment
Share on other sites

Hi,

If I have understood your question correctly, before submitting the form, you want to check whether the field has value less than 25 or not.

You are right that you need a JavaScript for this.

a hint:

var student = getElementById("InsertRecordfieldname");

var student_num = parsefloat(student.value);

if(student_num>25)

alert("Student number cant be more than 25");

There is another possible solution for this. If it is possible to have a range instead of exact number, you can have a range dropdown for this.

So you can have custom values:

Display Value

0-5 5

5-10 10

etc.

Regards,

Megha

Link to comment
Share on other sites

  • 9 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...