Skip to content

Commit b26b016

Browse files
committed
fix
1 parent 04d2b8c commit b26b016

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client/src/Components/NeedRoomComponent/NeedRoomComponent.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export const NeedRoomComponent = () => {
306306

307307
function validateNeedRoomForm() {
308308
const numericRegex = /^[0-9]+$/;
309+
const cgpaRegex = /^(10(?:\.0+)?|[0-9](?:\.\d+)?)$/;
309310
const indianNumberRegex = /^[6789]\d{9}$/;
310311
if (!needRoomForm["rank"]) {
311312
toast.error("Plase enter your CGPA");
@@ -337,7 +338,7 @@ export const NeedRoomComponent = () => {
337338
}
338339

339340
if (needRoomForm["rank"]) {
340-
let isRankValid = numericRegex.test(needRoomForm["rank"]);
341+
let isRankValid = cgpaRegex.test(needRoomForm["rank"]);
341342
if (!isRankValid) {
342343
toast.error("Please enter a valid CGPA");
343344
return false;
@@ -376,6 +377,7 @@ export const NeedRoomComponent = () => {
376377
function validateNeedRoomMateForm() {
377378
const numericRegex = /^[0-9]+$/;
378379
const indianNumberRegex = /^[6789]\d{9}$/;
380+
const cgpaRegex = /^(10(?:\.0+)?|[0-9](?:\.\d+)?)$/;
379381

380382
if (!needRoomMateForm["rank"]) {
381383
toast.error("Please enter your CGPA");
@@ -404,7 +406,7 @@ export const NeedRoomComponent = () => {
404406
}
405407

406408
if (needRoomMateForm["rank"]) {
407-
let isRankValid = numericRegex.test(needRoomMateForm["rank"]);
409+
let isRankValid = cgpaRegex.test(needRoomMateForm["rank"]);
408410
if (!isRankValid) {
409411
toast.error("Please enter a valid CGPA");
410412
return false;

0 commit comments

Comments
 (0)