Saturday 15 March 2014

jquery - return false not working on click of submit button -


One function is working on another page but this function calls here, shows an alert, but still the form Is submitted and is not working incorrectly ..... I am using razor to view

  @using (HTML.biz form (empty, empty, formmath.post, new {Enctype = "multipart / form-data"}))   

And here is my submit button

     

Thank you very much

  $ (function () {$ ('form'). Submit (function () {// alert ($ (" Input [type = radio]: check "). Val ()); if ($ (" input [type = radio]: checked "). Val () ==" True ") {// Logo image var selected file Val (); if (selected file == "") {Warning ('Please select a valid image logo for the market'); Return return;} and {var fileExtension = ['jpeg', ' 'Jpg', 'PNG', 'GIF', 'BMP'], if ($ .inter ($ ('$ imgfile') .val () .position ('.') .pop (.) ToLowerCase () File extension) = = -1) {warning ("You only have the permission to select '\ n.jpeg', '.jpg', '.png', '.gif', '.bmp' formats."); Return;}} // Screenshots if ($ ('$ Ssimgfile'). Val () == "" || $ ('# ssimgfile1'). Val () == "" || $ ('# ssimgfile2'). Val () == "" } {Return (return 'Please select a valid screenshot for the market'); Return;} Other {var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp']; ($ .inArray ($ ('$ ssimgfile') .Well (). Partition ('.') .POP (). ToLowerCase (), file extension) == -1 || $ .inArray ($ ('(# $' ssimgfile1 '). Val () .split ('. ') .pop (). ToLowerCase (), File Extension) == -1 || ($' ('Ssimgfile2' ) () () () () () (.). (Pop) (pop.) ToLowerCase (), fileExtension) == -1) {Warning ("You Only 'N.jpeg', '.jpg ',' .png ',' .gif ',' .bmp 'formats are allowed. "); return false; } And {return true; }}}}); });    

You need the "unset" button default event.

  $ ('form'). Submit (event (event) {event.preventDefault (); // your code is here});    

No comments:

Post a Comment