@@ -306,6 +306,7 @@ export const NeedRoomComponent = () => {
306306
307307 function validateNeedRoomForm ( ) {
308308 const numericRegex = / ^ [ 0 - 9 ] + $ / ;
309+ const cgpaRegex = / ^ ( 1 0 (?: \. 0 + ) ? | [ 0 - 9 ] (?: \. \d + ) ? ) $ / ;
309310 const indianNumberRegex = / ^ [ 6 7 8 9 ] \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 = / ^ [ 6 7 8 9 ] \d { 9 } $ / ;
380+ const cgpaRegex = / ^ ( 1 0 (?: \. 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