@@ -16,10 +16,7 @@ interface DataTableSearchFieldProps<TData>
1616 }
1717}
1818
19- const DataTableSearchField = < TData , > ( {
20- field,
21- table,
22- } : DataTableSearchFieldProps < TData > ) => {
19+ const DataTableSearchField = < TData , > ( { field, table } : DataTableSearchFieldProps < TData > ) => {
2320 const schema = getValidationSchema ( field . value )
2421 const handleInputChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
2522 const inputValue = event . target . value
@@ -30,11 +27,20 @@ const DataTableSearchField = <TData,>({
3027 } else {
3128 toast ( {
3229 title : validation . error . errors [ 0 ] . message ,
33- variant : 'destructive' ,
30+ variant : 'destructive'
3431 } ) // Set the error message
3532 }
3633 }
3734
35+ const onInputHandle = ( e : any ) => {
36+ if ( field . type == 'number' ) {
37+ const onlyNumber = [ 'seatingCount' , 'referenceNumber' ]
38+ if ( onlyNumber . includes ( field . value ) ) {
39+ e . target . value = e . target . value . replace ( / [ ^ 0 - 9 ] / g, '' )
40+ }
41+ }
42+ }
43+
3844 return (
3945 < div key = { field . value } className = "relative h-10" >
4046 < Input
@@ -47,6 +53,7 @@ const DataTableSearchField = <TData,>({
4753 ''
4854 }
4955 onChange = { handleInputChange }
56+ onInput = { onInputHandle }
5057 />
5158 < Label
5259 htmlFor = { field . value }
0 commit comments