 
                                    
                                    - 
                                              علی راستینارشدadmin@test.com
- پروفایل
- صندوق ورودی
- قفل صفحه
- خروج
- فرم ها
- اعتبار سنجی
ساده
نمونه کد
<!-- basic -->
<div x-data="form">
    <form class="space-y-5" @submit.prevent="submitForm1()">
        <div :class="[isSubmitForm1 ? (form1.name ? 'has-success' : 'has-error') : '']">
            <label for="fullName">Full Name</label>
            <input id="fullName" type="text" placeholder="Enter Full Name" class="form-input" x-model="form1.name" />
            <template x-if="isSubmitForm1 && form1.name">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm1 && !form1.name">
                <p class="text-danger mt-1">Please fill the Name</p>
            </template>
        </div>
        <button type="submit" class="btn btn-primary !mt-6">تایید</button>
    </form>
</div>
<!-- script -->
<script>
 document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form1: {
                name: ''
            },
            isSubmitForm1: false,
            submitForm1() {
                this.isSubmitForm1 = true;
                if (this.name) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>
                                
                            ایمیل
نمونه کد
<!-- email -->
<div x-data="form">
    <form class="space-y-5" @submit.prevent="submitForm2()">
        <div :class="[isSubmitForm2 ? (form2.email && emailValidate(form2.email)  ? 'has-success' : 'has-error') : '']">
            <label for="Email">Email</label>
            <input id="Email" type="text" placeholder="Enter Email" class="form-input" x-model="form2.email" />
            <template x-if="isSubmitForm2 && form2.email && emailValidate(form2.email)">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm2 && !(form2.email && emailValidate(form2.email))">
                <p class="text-danger mt-1">Please fill the Email</p>
            </template>
        </div>
        <button type="submit" class="btn btn-primary !mt-6">تایید</button>
    </form>
</div>
<!-- script -->
<script>
    document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form2: {
                email: ''
            },
            isSubmitForm2: false,
            emailValidate(email) {
                const regexp = /^[\w.%+-]+@[\w.-]+\.[\w]{2,6}$/;
                return regexp.test(email);
            },
            submitForm2() {
                this.isSubmitForm2 = true;
                if (this.emailValidate(this.form2.email)) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>
                                
                            Select لیست
نمونه کد
<!-- select -->
<div x-data="form">
    <form class="space-y-5" @submit.prevent="submitForm3()">
        <div :class="[isSubmitForm3 ? (form3.select ? 'has-success' : 'has-error') : '']">
            <select class="form-select text-white-dark" x-model="form3.select">
                <option>Open this select menu</option>
                <option>One</option>
                <option>Two</option>
                <option>Three</option>
            </select>
            <template x-if="isSubmitForm3 && form3.select">
                <p class="text-[#1abc9c] mt-1">Example valid custom select feedback</p>
            </template>
            <template x-if="isSubmitForm3 && !form3.select">
                <p class="text-danger mt-1">Please Select the field</p>
            </template>
        </div>
        <button type="submit" class="btn btn-primary !mt-6">تایید</button>
    </form>
</div>
<!-- script -->
<script>
 document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form3: {
                select: ''
            },
            isSubmitForm3: false,
            submitForm3() {
                this.isSubmitForm3 = true;
                if (this.form3.select) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>
                                
                            استایل های سفارشی
نمونه کد
<!-- custom styles -->
<form class="space-y-5" @submit.prevent="submitForm4()">
    <div class="grid grid-cols-1 md:grid-cols-3 gap-5">
        <div :class="[isSubmitForm4 ? (form4.firstName ? 'has-success' : 'has-error') : '']">
            <label for="customFname">نام</label>
            <input id="customFname" type="text" placeholder="نام را وارد کنید" class="form-input" x-model="form4.firstName" />
            <template x-if="isSubmitForm4 && form4.firstName">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.firstName">
                <p class="text-danger mt-1">نام خود را وارد کنید</p>
            </template>
        </div>
        <div :class="[isSubmitForm4 ? (form4.lastName ? 'has-success' : 'has-error') : '']">
            <label for="customLname">نام خانوادگی</label>
            <input id="customLname" type="text" placeholder="Enter Last Name" class="form-input" x-model="form4.lastName" />
            <template x-if="isSubmitForm4 && form4.lastName">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.lastName">
                <p class="text-danger mt-1">Please fill the last name</p>
            </template>
        </div>
        <div :class="[isSubmitForm4 ? (form4.userName ? 'has-success' : 'has-error') : '']">
            <label for="customeEmail">نام کاربری</label>
            <div class="flex">
                <div class="bg-[#eee] flex justify-center items-center ltr:rounded-l-md rtl:rounded-r-md px-3 font-semibold border ltr:border-r-0 rtl:border-l-0 border-[#e0e6ed] dark:border-[#17263c] dark:bg-[#1b2e4b]">@</div>
                <input id="customeEmail" type="text" placeholder="نام کاربری را وارد کنید" class="form-input ltr:rounded-l-none rtl:rounded-r-none" x-model="form4.userName" />
            </div>
            <template x-if="isSubmitForm4 && form4.userName">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.userName">
                <p class="text-danger mt-1">لطفا نام کاربری را وارد کنید</p>
            </template>
        </div>
    </div>
    <div class="grid grid-cols-1 md:grid-cols-4 gap-5">
        <div class="md:col-span-2" :class="[isSubmitForm4 ? (form4.city ? 'has-success' : 'has-error') : '']">
            <label for="customeCity">City</label>
            <input id="customeCity" type="text" placeholder="شهر را وارد کنید" class="form-input" x-model="form4.city" />
            <template x-if="isSubmitForm4 && form4.city">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.city">
                <p class="text-danger mt-1">لطفا شهر را به درستی وارد کنید</p>
            </template>
        </div>
        <div :class="[isSubmitForm4 ? (form4.state ? 'has-success' : 'has-error') : '']">
            <label for="customeState">State</label>
            <input id="customeState" type="text" placeholder="استان را وارد کنید" class="form-input" x-model="form4.state" />
            <template x-if="isSubmitForm4 && form4.state">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.state">
                <p class="text-danger mt-1">استان را به درستی وارد کنید</p>
            </template>
        </div>
        <div :class="[isSubmitForm4 ? (form4.zip ? 'has-success' : 'has-error') : '']">
            <label for="customeZip">Zip</label>
            <input id="customeZip" type="text" placeholder="Enter Zip" class="form-input" x-model="form4.zip" />
            <template x-if="isSubmitForm4 && form4.zip">
                <p class="text-[#1abc9c] mt-1">عالی!</p>
            </template>
            <template x-if="isSubmitForm4 && !form4.zip">
                <p class="text-danger mt-1">کد شهر را به درستی وارد کنید</p>
            </template>
        </div>
    </div>
    <div :class="[isSubmitForm4 ? (form4.isTerms ? 'has-success' : 'has-error') : '']">
        <label class="inline-flex cursor-pointer mt-1">
            <input type="checkbox" class="form-checkbox" x-model="form4.isTerms" />
            <span class="text-white-dark"  ">با شرایط و ضوابط موافقت کنید</span>
        </label>
        <template x-if="isSubmitForm4 && !form4.isTerms">
            <p class="text-danger mt-1">قبل از ارسال باید موافقت کنید.</p>
        </template>
    </div>
    <button type="submit" class="btn btn-primary !mt-6">تایید</button>
</form>
<!-- script -->
<script>
 document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form4: {
                firstName: 'محمد',
                lastName: 'کلانتر',
                userName: '',
                city: '',
                state: '',
                zip: '',
                isTerms: false
            },
            isSubmitForm4: false,
            submitForm4() {
                this.isSubmitForm4 = true;
                if (this.form4.firstName && this.form4.lastName && this.form4.userName && this.form4.city && this.form4.state && this.form4.zip && this.form4.isTerms) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>
                                
                            پیشفرض مرورگر
نمونه کد
<!-- browser default -->
<div x-data="form">
    <form class="space-y-5" @submit.prevent="submitForm5()">
        <div class="grid grid-cols-1 md:grid-cols-3 gap-5">
            <div>
                <label for="browserFname">نام</label>
                <input id="browserFname" type="text" placeholder="نام را وارد کنید" x-model="form5.firstName" class="form-input" required />
            </div>
            <div>
                <label for="browserLname">نام خانوادگی</label>
                <input id="browserLname" type="text" placeholder="نام خانوادگی را وارد کنید" x-model="form5.lastName" class="form-input" required />
            </div>
            <div>
                <label for="browserEmail">نام کاربری</label>
                <div class="flex">
                    <div class="bg-[#eee] flex justify-center items-center ltr:rounded-l-md rtl:rounded-r-md px-3 font-semibold border ltr:border-r-0 rtl:border-l-0 border-[#e0e6ed] dark:border-[#17263c] dark:bg-[#1b2e4b]">@</div>
                    <input id="browserEmail" type="text" placeholder="نام کاربری را وارد کنید" x-model="form5.userName" class="form-input ltr:rounded-l-none rtl:rounded-r-none" required />
                </div>
            </div>
        </div>
        <div class="grid grid-cols-1 md:grid-cols-4 gap-5">
            <div class="md:col-span-2">
                <label for="browserCity">City</label>
                <input id="browserCity" type="text" placeholder="شهر را وارد کنید" x-model="form5.city" class="form-input" required />
            </div>
            <div>
                <label for="browserState">State</label>
                <input id="browserState" type="text" placeholder="استان را وارد کنید" x-model="form5.state" class="form-input" required />
            </div>
            <div>
                <label for="browserZip">Zip</label>
                <input id="browserZip" type="text" placeholder="Enter Zip" x-model="form5.zip" class="form-input" required />
            </div>
        </div>
        <div>
            <label class="flex items-center cursor-pointer mt-1">
                <input type="checkbox" class="form-checkbox" x-model="form5.isTerms" require />
                <span class="text-white-dark"">با شرایط و ضوابط موافقت کنید</span>
            </label>
        </div>
        <button type="submit" class="btn btn-primary !mt-6">تایید</button>
    </form>
</div>
<!-- script -->
<script>
    document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form5: {
                firstName: 'محمد',
                lastName: 'کلانتر',
                userName: '',
                city: '',
                state: '',
                zip: '',
                isTerms: false
            },
            isSubmitForm5: false,
            submitForm5() {
                this.isSubmitForm5 = true;
                if (this.form5.firstName && this.form5.lastName && this.form5.userName && this.form5.city && this.form5.state && this.form5.zip && this.form5.isTerms) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>                    
                                
                            متن شناور
نمونه کد
<!-- tooltips -->
<div x-data="form">
    <form class="space-y-5" @submit.prevent="submitForm6()">
        <div class="grid grid-cols-1 md:grid-cols-3 gap-5">
            <div :class="[isSubmitForm6 ? (form6.firstName ? 'has-success' : 'has-error') : '']">
                <label for="tlpFname">نام</label>
                <input id="tlpFname" type="text" placeholder="نام را وارد کنید" class="form-input mb-2" x-model="form6.firstName" />
                <template x-if="isSubmitForm6 && form6.firstName">
                    <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                </template>
                <template x-if="isSubmitForm6 && !form6.firstName">
                    <span class="text-white bg-danger py-1 px-2 rounded">Please fill the first Name</span>
                </template>
            </div>
            <div :class="[isSubmitForm6 ? (form6.lastName ? 'has-success' : 'has-error') : '']">
                <label for="tlpLname">نام خانوادگی</label>
                <input id="tlpLname" type="text" placeholder="Enter Last Name" class="form-input mb-2" x-model="form6.lastName" />
                <template x-if="isSubmitForm6 && form6.lastName">
                    <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                </template>
                <template x-if="isSubmitForm6 && !form6.lastName">
                    <span class="text-white bg-danger py-1 px-2 rounded">Please fill the last Name</span>
                </template>
            </div>
            <div :class="[isSubmitForm6 ? (form6.userName ? 'has-success' : 'has-error') : '']">
                <label for="tlpEmail">نام کاربری</label>
                <div class="flex">
                    <div class="bg-[#eee] flex justify-center items-center ltr:rounded-l-md rtl:rounded-r-md px-3 font-semibold border ltr:border-r-0 rtl:border-l-0 border-[#e0e6ed] dark:border-[#17263c] dark:bg-[#1b2e4b]">@</div>
                    <input id="tlpEmail" type="text" placeholder="نام کاربری را وارد کنید" class="form-input ltr:rounded-l-none rtl:rounded-r-none" x-model="form6.userName" />
                </div>
                <div class="mt-2">
                    <template x-if="isSubmitForm6 && form6.userName">
                        <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                    </template>
                    <template x-if="isSubmitForm6 && !form6.userName">
                        <span class="text-white bg-danger py-1 px-2 rounded">لطفا نام کاربری را وارد کنید.</span>
                    </template>
                </div>
            </div>
        </div>
        <div class="grid grid-cols-1 md:grid-cols-4 gap-5">
            <div class="md:col-span-2" :class="[isSubmitForm6 ? (form6.city ? 'has-success' : 'has-error') : '']">
                <label for="tlpCity">City</label>
                <input id="tlpCity" type="text" placeholder="شهر را وارد کنید" class="form-input mb-2" x-model="form6.city" />
                <template x-if="isSubmitForm6 && form6.city">
                    <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                </template>
                <template x-if="isSubmitForm6 && !form6.city">
                    <span class="text-white bg-danger py-1 px-2 rounded">لطفا شهر را به درستی وارد کنید.</span>
                </template>
            </div>
            <div :class="[isSubmitForm6 ? (form6.state ? 'has-success' : 'has-error') : '']">
                <label for="tlpState">State</label>
                <input id="tlpState" type="text" placeholder="استان را وارد کنید" class="form-input mb-2" x-model="form6.state" />
                <template x-if="isSubmitForm6 && form6.state">
                    <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                </template>
                <template x-if="isSubmitForm6 && !form6.state">
                    <span class="text-white bg-danger py-1 px-2 rounded">استان را به درستی وارد کنید.</span>
                </template>
            </div>
            <div :class="[isSubmitForm6 ? (form6.zip ? 'has-success' : 'has-error') : '']">
                <label for="tlpZip">Zip</label>
                <input id="tlpZip" type="text" placeholder="Enter Zip" class="form-input mb-2" x-model="form6.zip" />
                <template x-if="isSubmitForm6 && form6.zip">
                    <span class="text-white bg-[#1abc9c] py-1 px-2 rounded">عالی!</span>
                </template>
                <template x-if="isSubmitForm6 && !form6.zip">
                    <span class="text-white bg-danger py-1 px-2 rounded">Please provide a valid Zip.</span>
                </template>
            </div>
        </div>
        <div :class="[isSubmitForm6 ? (form6.isTerms ? 'has-success' : 'has-error') : '']">
            <label class="flex items-center cursor-pointer">
                <input type="checkbox" class="form-checkbox" x-model="form6.isTerms" />
                <span class="text-white-dark"">با شرایط و ضوابط موافقت کنید</span>
            </label>
            <template x-if="isSubmitForm6 && !form6.isTerms">
                <div class="mt-2">
                    <span class="text-white bg-danger py-1 px-2 rounded">قبل از ارسال باید موافقت کنید.</span>
                </div>
            </template>
        </div>
        <button type="submit" class="btn btn-primary !mt-6">تایید</button>
    </form>
<div>
<!-- script -->
<script>
 document.addEventListener("alpine:init", () => {
        Alpine.data("form", () => ({
            form6: {
                firstName: 'محمد',
                lastName: 'کلانتر',
                userName: '',
                city: '',
                state: '',
                zip: '',
                isTerms: false
            },
            isSubmitForm6: false,
            submitForm6() {
                this.isSubmitForm6 = true;
                if (this.form6.firstName && this.form6.lastName && this.form6.userName && this.form6.city && this.form6.state && this.form6.zip && this.form6.isTerms) {
                    //form validated success
                    this.showMessage('Form submitted successfully.');
                }
            },
            showMessage(msg = '', type = 'success') {
                const toast = window.Swal.mixin({
                    toast: true,
                    position: 'top',
                    showConfirmButton: false,
                    timer: 3000
                });
                toast.fire({
                    icon: type,
                    title: msg,
                    padding: '10px 20px'
                });
            },
        }));
    });
</script>
                                
                            
                    ©  روشاک