![]() |
#1 |
Registered User
Join Date: Dec 2013
Posts: 327
|
data validation
How to do data validation while submitting form?
|
![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Jul 2014
Location: Athens, Greece
Posts: 461
![]() |
You validate your data with javascript, before sending them to the server.
Example: <form id="contact_form" method="post" enctype="multipart/form-data" action="contact.php" > <input type="text" value="" name="name" id="name" /> <input type="text" value="" name="email" id="email" /> <input type="text" value="" name="phone" id="phone" /> <textarea name="comments" id="comments"></textarea> <input type="button" class="submit_button" value="SUBMIT" onclick="return validate_contact();" /> </form> And in javascript: function validate_contact(){ var name=jQuery.trim($('#name').val()); var email=jQuery.trim($('#email').val()); var comments=jQuery.trim($('#comments').val()); if (name=='' || name.length<3) {alert ('Please enter your name');return false;} if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)==false) {alert('Please enter valid email address');return false;} if (comments.length<1) {alert('Please enter your comments');return false;} }
__________________
Κατασκευή ιστοσελίδων | κατασκευή Δημιουργία site | Σχεδιασμός ανάπτυξη site | e-shop | Σχεδιασμός ιστοσελίδων |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Data Entry Outsourcing Services | shrikant.softwi | Post your ad here | 3 | 10-10-2018 11:57 PM |
How to Find Remunerative Data Entry Jobs | menchester03 | Making money on the web | 3 | 12-28-2014 01:57 PM |
Google Analytics vs Webmaster Tools Data | James12smith | Search Engine Optimization | 0 | 01-13-2014 10:14 PM |
Requires Data Entry operator ! | rmonline11 | General Discussion | 2 | 05-08-2012 09:54 AM |