tags:

views:

85

answers:

1

hi

 how to set a max value for a text box in javascript .....

eg.. the value must be with in 100... no greater value must be entered i my task i am using two text box where i am inserting marks ... the first text box my marks will be out of 80 the second will be out of 20 i am calculating the total of 1st and 2nd mark and the result will be in another text box the mark for third text box will be 100

now my query is how set the maximum value for the values for mark 1 mark2 and total as 80,20 and 100 respectively mark1/80 mark2/20 total/100 qqq 80 20 100

+1  A: 

add onsubmit to the form and set to a custom function like onsubmit="return mycheck();" There you can get your textobx using document.getElementById() and their values with .value. To get a number just do var thenumber = new Number(document.getElementById('theid').value); then do whatever check you need with the number and return true if all its ok or false if it isnt.

useless