Guest User

Untitled

a guest
Oct 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <script>
  2.  
  3. function validateform() {
  4.  
  5. var email = $('#txt_emailID').val();
  6. if (email == null || email == "") {
  7. alert("Email Should Be Complusory");
  8. return false;
  9. }
  10. var atposition = email.indexOf("@");
  11. var dotposition = email.lastIndexOf(".");
  12. if (atposition < 1 || dotposition < atposition + 2 || dotposition + 2 >= email.length) {
  13. alert("Please enter a valid e-mail address...!!!");
  14. return false;
  15. }
  16. }
  17.  
  18. </script>
  19.  
  20. <label for="fname">Name</label>
  21. <input type="text" id="txt_name" name="txt_name" placeholder="Your Name.." />
  22.  
  23. <label for="lname">EmailID</label>
  24. <input type="text" id="txt_emailID" name="email" placeholder="Your EmailID.." />
  25.  
  26. <label for="lname">Subject</label>
  27. <input type="text" id="txt_subject" name="txt_subject" placeholder="Your Subject.." />
  28.  
  29. <input type="submit" id="submit_mail" value="Send" />
  30.  
  31. <script>
  32. $(function () {
  33. $(document).on("click", "#submit_mail", function () {
  34. if (validateform() == false) {
  35. document.getElementById("txt_name").value = $('#txt_name').val();
  36. document.getElementById("txt_subject").value = $('#txt_subject').val();
  37.  
  38. }
  39. else {
  40.  
  41. }
  42. });
  43. });
Add Comment
Please, Sign In to add comment