luci-proto-3g: add APN and PIN validation

Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
[squash commits, fix whitespace]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 6a8ad40b05)
This commit is contained in:
Nicholas Smith 2021-06-11 22:40:30 +10:00 committed by Jo-Philipp Wich
parent badce00804
commit 9a802398f1

View file

@ -92,8 +92,17 @@ return network.registerProtocol('3g', {
o.value('gprs_only', _('GPRS only'));
o.value('evdo', 'CDMA/EV-DO');
s.taboption('general', form.Value, 'apn', _('APN'));
s.taboption('general', form.Value, 'pincode', _('PIN'));
o = s.taboption('general', form.Value, 'apn', _('APN'));
o.validate = function(section_id, value) {
if (!/^[a-zA-Z0-9\-.]*[a-zA-Z0-9]$/.test(value))
return _('Invalid APN provided');
return true;
};
o = s.taboption('general', form.Value, 'pincode', _('PIN'));
o.datatype = 'and(uinteger,minlength(4),maxlength(8))';
s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));