Compare commits

..

No commits in common. "f5a442311aa2ab727592560486c0c2429b27ccd6" and "f6ca6297eac2b5e55f3f646291dc938d7a7c86f3" have entirely different histories.

4 changed files with 21 additions and 30 deletions

View File

@ -41,8 +41,7 @@ export default function LoginForm({
const handlePhoneChange = (text: string) => {
const digits = text.replace(/\D/g, "");
setPhone(digits.slice(0, 15));
if (phoneError) setPhoneError("");
setPhone(digits.slice(0, 10));
};
const handleLogin = async () => {
@ -63,8 +62,8 @@ export default function LoginForm({
if (!phone.trim()) {
setPhoneError("Phone number is required");
hasError = true;
} else if (phone.length < 7 || phone.length > 15) {
setPhoneError("Phone number must be between 7 and 15 digits");
} else if (phone.length < 10) {
setPhoneError("Phone number must be 10 digits");
hasError = true;
}
}
@ -131,7 +130,7 @@ export default function LoginForm({
autoCapitalize="none"
autoCorrect={false}
textContentType="telephoneNumber"
maxLength={15}
maxLength={10}
leftIcon="call-outline"
error={phoneError}
/>

View File

@ -65,7 +65,7 @@ export default function SignUpForm() {
const handlePhoneChange = (text: string) => {
const digits = text.replace(/\D/g, "");
setPhone(digits.slice(0, 15));
setPhone(digits.slice(0, selectedCountry.maxLength));
if (phoneError) setPhoneError("");
};
@ -73,8 +73,8 @@ export default function SignUpForm() {
setSelectedCountry(c);
setShowCountryModal(false);
setCountrySearch("");
if (phone.length > 15) {
setPhone(phone.slice(0, 15));
if (phone.length > c.maxLength) {
setPhone(phone.slice(0, c.maxLength));
}
if (phoneError) setPhoneError("");
};
@ -101,9 +101,13 @@ export default function SignUpForm() {
}
if (phone.trim()) {
const digits = phone.trim().replace(/\D/g, "");
if (digits.length < 7 || digits.length > 15) {
setPhoneError("Phone number must be between 7 and 15 digits");
const err = validatePhoneNumber(
phone,
selectedCountry.code,
selectedCountry.country
);
if (err) {
setPhoneError(err);
hasError = true;
}
}
@ -231,7 +235,7 @@ export default function SignUpForm() {
autoCapitalize="none"
autoCorrect={false}
textContentType="telephoneNumber"
maxLength={15}
maxLength={selectedCountry.maxLength}
style={styles.phoneInput}
/>
</View>

View File

@ -57,8 +57,8 @@ export const isValidPhoneNumber = (val?: string): boolean => {
return false;
}
const digits = trimmed.replace(/\D/g, "");
// ITU-T E.164 standard: minimum 7 and maximum 15 digits
return digits.length >= 7 && digits.length <= 15;
// ITU-T E.164 standard allows 6 to 15 digits
return digits.length >= 6 && digits.length <= 15;
};
const cleanPhoneInput = (text: string): string => {
@ -66,19 +66,7 @@ const cleanPhoneInput = (text: string): string => {
const hasPlus = trimmedStart.startsWith("+");
const rest = hasPlus ? trimmedStart.slice(1) : text;
const filtered = rest.replace(/[^0-9\s\-()]/g, "");
let digitCount = 0;
let bounded = "";
for (const ch of filtered) {
if (/\d/.test(ch)) {
if (digitCount < 15) {
digitCount++;
bounded += ch;
}
} else {
bounded += ch;
}
}
return hasPlus ? `+${bounded}` : bounded;
return hasPlus ? `+${filtered}` : filtered;
};
export default function EditProfileForm({
@ -138,7 +126,7 @@ export default function EditProfileForm({
const trimmedPhone = phone.trim();
if (trimmedPhone && !isValidPhoneNumber(trimmedPhone)) {
setPhoneError("Phone number must be between 7 and 15 digits");
setPhoneError("Please enter a valid phone number");
hasError = true;
}
@ -183,7 +171,7 @@ export default function EditProfileForm({
onChangeText={handlePhoneChange}
placeholder="e.g. +91 9876543210"
keyboardType="phone-pad"
maxLength={16}
maxLength={25}
textContentType="telephoneNumber"
autoCapitalize="none"
autoCorrect={false}

View File

@ -41,7 +41,7 @@ export default function EditProfileScreen() {
const trimmedCountry = updatedCountry.trim();
if (trimmedPhone && !isValidPhoneNumber(trimmedPhone)) {
const errMsg = "Phone number must be between 7 and 15 digits";
const errMsg = "Please enter a valid phone number";
if (Platform.OS === "web") {
window.alert(errMsg);
} else {