|
| 1 | +import { Input, Typography } from "@material-tailwind/react"; |
| 2 | + |
| 3 | +export function InputPhoneValidation() { |
| 4 | + return ( |
| 5 | + <div className="space-y-8"> |
| 6 | + <div className="w-96"> |
| 7 | + <Typography |
| 8 | + variant="small" |
| 9 | + color="blue-gray" |
| 10 | + className="mb-1 font-medium" |
| 11 | + > |
| 12 | + Contact Number |
| 13 | + </Typography> |
| 14 | + <Input |
| 15 | + success={true} |
| 16 | + maxLength={16} |
| 17 | + placeholder="e.g., +1 123-456-7890" |
| 18 | + pattern="^\+\d{1,3}\s\d{1,4}-\d{1,4}-\d{4}$" |
| 19 | + className="appearance-none !border-t-green-500 placeholder:text-green-300 placeholder:opacity-100 focus:!border-t-green-500 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none" |
| 20 | + labelProps={{ |
| 21 | + className: "before:content-none after:content-none", |
| 22 | + }} |
| 23 | + /> |
| 24 | + <Typography color="green" className="mt-2 text-xs font-normal"> |
| 25 | + Great! Your phone number is valid. |
| 26 | + </Typography> |
| 27 | + </div> |
| 28 | + <div className="w-96"> |
| 29 | + <Typography |
| 30 | + variant="small" |
| 31 | + color="blue-gray" |
| 32 | + className="mb-1 font-medium" |
| 33 | + > |
| 34 | + Contact Number |
| 35 | + </Typography> |
| 36 | + <Input |
| 37 | + error={true} |
| 38 | + maxLength={16} |
| 39 | + placeholder="e.g., +1 123-456-7890" |
| 40 | + pattern="^\+\d{1,3}\s\d{1,4}-\d{1,4}-\d{4}$" |
| 41 | + className="appearance-none !border-t-red-500 placeholder:text-red-300 placeholder:opacity-100 focus:!border-t-red-500 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none" |
| 42 | + labelProps={{ |
| 43 | + className: "before:content-none after:content-none", |
| 44 | + }} |
| 45 | + /> |
| 46 | + <Typography |
| 47 | + color="red" |
| 48 | + className="mt-2 flex items-center gap-2 text-xs font-normal" |
| 49 | + > |
| 50 | + <svg |
| 51 | + xmlns="http://www.w3.org/2000/svg" |
| 52 | + viewBox="0 0 24 24" |
| 53 | + fill="currentColor" |
| 54 | + className="h-5 w-5" |
| 55 | + > |
| 56 | + <path |
| 57 | + fill-rule="evenodd" |
| 58 | + d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm8.706-1.442c1.146-.573 2.437.463 2.126 1.706l-.709 2.836.042-.02a.75.75 0 01.67 1.34l-.04.022c-1.147.573-2.438-.463-2.127-1.706l.71-2.836-.042.02a.75.75 0 11-.671-1.34l.041-.022zM12 9a.75.75 0 100-1.5.75.75 0 000 1.5z" |
| 59 | + clip-rule="evenodd" |
| 60 | + ></path> |
| 61 | + </svg> |
| 62 | + Please match the requested format. e.g., +1 123-456-7890 |
| 63 | + </Typography> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + ); |
| 67 | +} |
0 commit comments