xxxxxxxxxx
// make input safe from injections/malicious coding
export const sanitizeInput = (input: string, allowedChars: RegExp): string => {
return input.replace(allowedChars, '')
}
<FormItem className="space-y-1.5">
<FormLabel className="text-neutral-mediumGray font-medium text-base">
Full Name
</FormLabel>
<FormControl>
<Input
className="rounded-full"
{field}
onChange={(e) =>
field.onChange(
sanitizeInput(e.target.value, /[^a-zA-Z\s]/g)
)
}
/>
</FormControl>
<FormMessage />
</FormItem>
/>
<FormItem className="space-y-1.5">
<FormLabel className="text-neutral-mediumGray font-medium text-base">
Email Address
</FormLabel>
<FormControl>
<Input
className="rounded-full"
{field}
onChange={(e) =>
field.onChange(
sanitizeInput(e.target.value, /[^a-zA-Z0-9@._-]/g)
)
}
/>
</FormControl>
<FormMessage />
</FormItem>
<FormField
control={form.control}
name="company_name"
render={({ field }) => (
<FormItem className="space-y-1.5">
<FormLabel className="text-neutral-mediumGray font-medium text-base">
Company Name
</FormLabel>
<FormControl>
<Input
className="rounded-full"
{field}
onChange={(e) =>
field.onChange(
sanitizeInput(e.target.value, /[^a-zA-Z0-9-_\s]/g)
)
}
/>
</FormControl>
<FormMessage />
</FormItem>
Under the `build` folder add an app.js file with the following:
xxxxxxxxxx
const express = require('express');
const app = express();
const port = 8000;
app.get('/', (req, res) => {
console.log('getting request');
res.sendFile('index.html', { root: __dirname });
});
app.use(express.static(__dirname + '/'));
app.use((req, res) => {
res.redirect('/');
});
app.listen(port, () => {
console.log(`app listening at http://localhost:${port}`);
});
To run:
npm init
npm install express --no-save
node app.js