Home > Mobile >  Html Form data not submitting correctly - hidden input field not sending the full string
Html Form data not submitting correctly - hidden input field not sending the full string

Time:11-03

This is the hidden field in the form ( I'm parsing an id from MongoDb collection )

<input type="hidden" value="6363a9f2e80ad43cdffa604d" name="remove"\>

and this is the Node js code


app.post('/deleteItem', function(req, res) {

  let itemToBeRemoved = parseInt(req.body.remove);
  console.log(itemToBeRemoved  ' is received ') // 6363 is received 

});

this is really strange, but dooes anyone knows the reason ?

the result should be the full string 6363a9f2e80ad43cdffa604d is received .

but it always console log

6363 is received

I need to receive the full string from the hidden input. but I only receive the first 4 characters from it. which is strange

CodePudding user response:

You are trying to parse "6363a9f2e80ad43cdffa604d" into an int with parseInt. Remove the parseInt call and it will work.

  • Related