I'm fairly new to Commerce Cloud; I've added a custom textfield. I want to override the form submission that takes place on the click of the Apply Button so that I can read the value from this new field. I'm working on the sample SiteGenesis site. Any help in this regard would be very helpful.
to process a form submission you need to write a controller in server side javascript which needs to be installed in an appropriate cartridge. It seems like you are trying to create a form as a content asset. This is not the recommended approach instead you should create a controller together with some templates that manages this task.
a simple controller looks like this:
'use strict';
var server = require('server');
var cache = require('*/cartridge/scripts/middleware/cache');
server.get('World', cache.applyDefaultCache, function (req, res, next) {
res.render('helloworld', {
Message: 'Hello World! Again.'
});;
next();
});
module.exports = server.exports();