National ID input validation added

development_v3.3
haroon amjad 1 year ago
parent 6e30df2a29
commit 5f90435442

@ -126,11 +126,13 @@ class _Login extends State<Login> {
), ),
DefaultButton( DefaultButton(
TranslationBase.of(context).login, TranslationBase.of(context).login,
isButtonDisabled () {
? null if (isButtonDisabled) {
: () { AppToast.showErrorToast(message: "National ID can only contain numbers");
this.startLogin(); } else {
}, this.startLogin();
}
},
disabledColor: Color(0xff575757), disabledColor: Color(0xff575757),
), ),
]), ]),
@ -227,7 +229,7 @@ class _Login extends State<Login> {
} }
void validateForm() { void validateForm() {
if (util.validateIDBox(nationalIDorFile.text, loginType) == true && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { if (util.validateIDBox(nationalIDorFile.text, loginType) == true && (countryCode == "971" ? true : util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true)) {
setState(() { setState(() {
isButtonDisabled = false; isButtonDisabled = false;
}); });
@ -257,16 +259,16 @@ class _Login extends State<Login> {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
authService.checkPatientAuthentication(request).then((value) { authService.checkPatientAuthentication(request).then((value) {
// if (value['UserAccountIsActivated']) { // if (value['UserAccountIsActivated']) {
if (value['isSMSSent']) { if (value['isSMSSent']) {
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']);
sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request); sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).push(FadePage(page: ConfirmLogin())); Navigator.of(context).push(FadePage(page: ConfirmLogin()));
} else { } else {
if (value['IsAuthenticated']) { if (value['IsAuthenticated']) {
this.checkActivationCode(); this.checkActivationCode();
}
} }
}
// } else { // } else {
// ConfirmDialog activationDialog = new ConfirmDialog( // ConfirmDialog activationDialog = new ConfirmDialog(
// context: context, // context: context,

@ -166,12 +166,13 @@ class Utils {
Pattern pattern = loginIDPattern(type); //r'^\d+(?:\.\d+)?$'; Pattern pattern = loginIDPattern(type); //r'^\d+(?:\.\d+)?$';
RegExp regex = new RegExp(pattern); RegExp regex = new RegExp(pattern);
print(regex.hasMatch(value));
return regex.hasMatch(value); return regex.hasMatch(value);
} }
String loginIDPattern(loginType) { String loginIDPattern(loginType) {
var length = loginType == 1 ? 10 : 1; var length = loginType == 1 ? 10 : 1;
return "([0-9]{" + length.toString() + "})"; return "([0-9]{" + length.toString() + "}\$)";
} }
static showProgressDialog(context, [String message = "Loading..."]) async { static showProgressDialog(context, [String message = "Loading..."]) async {

Loading…
Cancel
Save