Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added disabled option #70

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/assets/scss/form/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
background-color: white;
color:black;
}

&:disabled{
opacity: 20;
cursor: not-allowed;
}
}


Expand Down
6 changes: 4 additions & 2 deletions src/components/Form/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Form = () => {
const [usnInput, setUsnInput] = useState("")
const [regInput, setRegInput] = useState("")
const [display, setDisplay] = useState(false)
const [disabled,setDisabled] = useState(false)
const usnRegex = /^1DS\w{7}$/
const phoneRegex = /^\d{10}$/
const admnRegex = /^23UGDS\w{4}$/
Expand Down Expand Up @@ -53,7 +54,6 @@ const Form = () => {
toast.error("Please Enter correct Admission No.", { duration: 2500 })
return
}

}
else {
if (!usnRegex.test(usn)) {
Expand All @@ -63,6 +63,7 @@ const Form = () => {

}
let savingToast = toast.loading("Saving Data");
setDisabled(true)
const data = await fetch("https://h1so0s7f9i.execute-api.us-east-1.amazonaws.com/Prod/", {
method: "POST",
headers: {
Expand All @@ -84,6 +85,7 @@ const Form = () => {
setUsnInput("")
setRegInput("")
reset()
setDisabled(false)
setDisplay(false);

}
Expand Down Expand Up @@ -148,7 +150,7 @@ const Form = () => {
<label className='form-label' htmlFor="whatsapp">Tell us something about yourself {"("}max 150 words{"}"} <span style = {{color:"red"}}>*</span></label>
<textarea placeholder='I am a....' rows={6} required {...register("bio")} type="tel" className='input-box' />
</div>
<button type="submit" className='form-btn'>Submit</button>
<button disabled = {disabled} type="submit" className='form-btn'>Submit</button>
</div>

</form>
Expand Down