mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-17 21:40:30 +00:00
input check
This commit is contained in:
parent
f0aff9a872
commit
cec35f3b6d
@ -45,6 +45,10 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
||||
}
|
||||
};
|
||||
|
||||
const validateInput = (input) => {
|
||||
return input.replace(/[^a-zA-Z]/g, '');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
{noServers ? (
|
||||
@ -67,7 +71,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
||||
className={styles.inputsubdomain}
|
||||
type="text"
|
||||
value={subdomainInput}
|
||||
onChange={(e) => setSubdomainInput(e.target.value)}
|
||||
onChange={(e) => setSubdomainInput(validateInput(e.target.value))}
|
||||
placeholder='Nom du sous domaine'
|
||||
/>
|
||||
<button className={styles.btnSubCreate} onClick={handleSaveSubdomain}>
|
||||
@ -85,7 +89,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
|
||||
type="text"
|
||||
placeholder="Nom du serveur"
|
||||
value={serverName}
|
||||
onChange={(e) => setServerName(e.target.value)}
|
||||
onChange={(e) => setServerName(validateInput(e.target.value))}
|
||||
/>
|
||||
<select
|
||||
className={styles.select}
|
||||
|
@ -35,9 +35,14 @@ const ServerDetails = ({ user }) => {
|
||||
fetchServer();
|
||||
}, [serverName]);
|
||||
|
||||
const validateInput = (input) => {
|
||||
return input.replace(/[^a-zA-Z]/g, '');
|
||||
};
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { name, value } = e.target;
|
||||
setServer({ ...server, [name]: value });
|
||||
const validatedValue = name === 'motd' ? validateInput(value) : value;
|
||||
setServer({ ...server, [name]: validatedValue });
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
@ -53,14 +58,12 @@ const ServerDetails = ({ user }) => {
|
||||
['pvp', server.pvp.toString()]
|
||||
];
|
||||
|
||||
|
||||
|
||||
await serviiApi.updateProperties(server.name, props);
|
||||
} catch (error) {
|
||||
console.error('Error updating server:', error);
|
||||
alert('Error updating server');
|
||||
}
|
||||
handleQuit()
|
||||
handleQuit();
|
||||
};
|
||||
|
||||
const handleQuit = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user