Aurangajeb

Disable an input field for the user for a specific page that contains any strings

Apr 29th, 2021 (edited)
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Disable an input field for the user for a specific page that contains any strings
  2. /* This below code will run on the WPUF edit page, and it will disable the phone field on the edit page only like- https://ibb.co/nkpXMJ0 */
  3.  
  4. jQuery(document).ready(function( $ ){
  5.       // Your code in here
  6.  
  7.         if (window.location.href.indexOf("edit") > -1) {
  8.         $( "#phone_107" ).prop( "disabled", true );
  9.           $(document).on('click',function(e){
  10.             if(e.target.id == "phone_107"){
  11.               alert("You can't edit this field after submission.");
  12.             }
  13.          });
  14.       }
  15. });
  16.  
Add Comment
Please, Sign In to add comment